Advertisement
Trescon

prova_db_presepe_classe.py

Aug 8th, 2018
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.36 KB | None | 0 0
  1. # Prova_db_presepe
  2.  
  3. class PRESEPE_SALVA():
  4.     def presepe_salva(self,dati):
  5.         self.dati = dati
  6.         import sqlite3
  7.  
  8.         conn = sqlite3.connect('presepe.db')
  9.         c = conn.cursor()
  10.  
  11.         # Crea Tabella
  12.         c.execute('''CREATE TABLE IF NOT EXISTS scheda_1 (evento TEXT, time TEXT, rele_8 TEXT, rele_7 TEXT, rele_6 TEXT,rele_5 TEXT,rele_4 TEXT,rele_3 TEXT,rele_2 TEXT,rele_1 TEXT)''')
  13.         c.execute('''CREATE TABLE IF NOT EXISTS scheda_2 (evento INTEGER, time INTEGER, rele_8 INTEGER, rele_7 INTEGER, rele_6 INTEGER,rele_5 INTEGER,rele_4 INTEGER,rele_3 INTEGER,rele_2 INTEGER,rele_1 INTEGER)''')
  14.         c.execute('''CREATE TABLE IF NOT EXISTS scheda_3(evento INTEGER, time INTEGER, rele_8 INTEGER, rele_7 INTEGER, rele_6 INTEGER,rele_5 INTEGER,rele_4 INTEGER,rele_3 INTEGER,rele_2 INTEGER,rele_1 INTEGER)''')
  15.         c.execute('''Create TABLE IF NOT EXISTS scheda_4 (evento INTEGER, time INTEGER, rele_8 INTEGER, rele_7 INTEGER, rele_6 INTEGER,rele_5 INTEGER,rele_4 INTEGER,rele_3 INTEGER,rele_2 INTEGER,rele_1 INTEGER)''')
  16.             # Inserisce una riga di dati
  17.         c.executemany("INSERT INTO scheda_1 VALUES (?,?,?,?,?,?,?,?,?,?)",self.dati) #(1,20,61,61,61,60,60,61,60,60)")
  18.         c.execute("INSERT INTO scheda_2 VALUES (1,50,60,61,60,61,61,60,61,61)")
  19.         c.execute("INSERT INTO scheda_3 VALUES (1,70,60,60,61,60,61,61,60,61)")
  20.         c.execute("INSERT INTO scheda_4 VALUES (1,90,61,61,60,61,60,60,61,60)")
  21.  
  22.             #purchases = [('2006-03-28','BUY','IBM',1000,45.00),
  23.             #            ('2006-04-05','BUY','MSFT',1000,72.00),
  24.             #             ('2006-04-06','SELL','IBM',500,53.00),
  25.             #             ]
  26.             #c.executemany('INSERT INTO stocks VALUES (?,?,?,?,?)',purchases)
  27.  
  28.             # Salva (commit) i cambiamenti
  29.         conn.commit()
  30.  
  31.         for row in c.execute('SELECT * FROM scheda_2 ORDER BY time'):
  32.             print (row)
  33. pos = PRESEPE_SALVA()
  34.  
  35. #for articolo in dati:
  36. #   a=a+1
  37. #   print(a)
  38. #   print(articolo[0],articolo[1],articolo[2],articolo[3],articolo[4],articolo[5],articolo[6],articolo[7])
  39. #
  40. #   purchases1 = [(articolo[0],articolo[1],articolo[2],articolo[3],articolo[4],articolo[5],articolo[6],articolo[7])]
  41. #   c.executemany('INSERT INTO FSCCDET VALUES (?,?,?,?,?,?,?,?)',purchases1)
  42. #   conn.commit()
  43.  
  44. #print(purchases1.index)
  45.  
  46. #for row in c.execute('SELECT * FROM FSCCDET ORDER BY data_start'):
  47. #    print (row)
  48.  
  49.  
  50. # tolta per il momento c.execute('''CREATE TABLE IF NOT EXISTS tim (date text, trans text, symbol text, qty real, price real)''')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement