-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQL.py
31 lines (25 loc) · 846 Bytes
/
SQL.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
__author__ = 'erick'
import sqlite3
class SQL(object):
def __init__(self):
self.database = sqlite3.connect('temperatura')
self.cursor = self.database.cursor()
def dataWrite(self, temperatura, hora):
try:
self.cursor.execute("INSERT INTO tiempotemperatura (TEMPERATURA, HORA)\
VALUES (%d, %s)" %(temperatura, hora))
self.database.commit()
print("Valor Agregado Correctamente")
except:
self.database.rollback()
print("Error al agregar valores")
def dataRead(self):
try:
self.cursor.execute("SELECT * FROM tiempotemperatura")
data = self.cursor.fetchall()
return data
except:
print("error en la lectura")
def dataSave(self):
pass