Advertisement
Guest User

Untitled

a guest
May 6th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys, os, sqlite3
  4. from time import strftime, localtime
  5. sys.path.insert(0, '/home/pi/ADC/1x15/')
  6. from CO2 import co2
  7.  
  8. if os.path.isfile("valeur.sqlite"):
  9.         print "La BDD existe :"
  10.         con = sqlite3.connect("valeur.sqlite")
  11.         con.isolation_level = None
  12.         cur = con.cursor()
  13.  
  14.         Time = strftime("%H:%M:%S", localtime())
  15.  
  16.         cur.execute('INSERT INTO CO2 VALUES (?,?)', (Time,co2()))
  17.  
  18.         cur.execute("SELECT * FROM CO2")
  19.         for l in cur:
  20.                 print(l)
  21.  
  22.         con.commit()
  23.         con.close()
  24. else:
  25.         print "BDD inexistante, creation"
  26.         con = sqlite3.connect("valeur.sqlite")
  27.         con.isolation_level = None
  28.         cur = con.cursor()
  29.  
  30.         cur.execute("CREATE TABLE CO2 (time TEXT, qty REAL)")
  31.  
  32.         con.commit()
  33.         con.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement