-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql.py
25 lines (18 loc) · 848 Bytes
/
mysql.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sqlite3 as lite
import sys
def guardar_peso(usuario, peso):
con = lite.connect(usuario + '_fitbit.db')
with con:
cur = con.cursor()
#weight table
#cur.execute("CREATE TABLE IF NOT EXISTS weight(CURRENT_DATE DATETIME PRIMARY KEY NOT NULL DEFAULT (CURRENT_DATE), weight REAL)")
cur.execute("INSERT OR REPLACE INTO weight (CURRENT_DATE, weight) VALUES (DATE('now'), "+str(peso)+")")
def crear_tabla(db_file):
con = lite.connect(db_file)
with con:
cur = con.cursor()
#weight table
cur.execute("CREATE TABLE IF NOT EXISTS weight(CURRENT_DATE DATETIME PRIMARY KEY NOT NULL DEFAULT (CURRENT_DATE), weight REAL)")
#cur.execute("INSERT OR REPLACE INTO weight (CURRENT_DATE, weight) VALUES (DATE('now'), "+str(peso)+")")