You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import os
|
|
|
|
i = 1
|
|
|
|
"""
|
|
|
|
cursor = self.conn.cursor()
|
|
|
|
|
|
|
|
r = cursor.execute(sql)
|
|
|
|
r = r.fetchall()
|
|
|
|
cursor.close()
|
|
|
|
|
|
|
|
return r[0][0]
|
|
|
|
except Exception as e:
|
|
|
|
pass
|
|
|
|
return 0
|
|
|
|
#
|
|
|
|
# If the table doesn't exist we should create it
|
|
|
|
#
|
|
|
|
def write(self,info):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not self.fields :
|
|
|
|
self.init(list(info.keys()))
|
|
|
|
|
|
|
|
if type(info) != list :
|
|
|
|
info = [info]
|
|
|
|
cursor = self.conn.cursor()
|
|
|
|
|
|
|
|
|
|
|
|
sql = " " .join(["INSERT INTO ",self.table,"(", ",".join(self.fields) ,")", "values(':values')"])
|
|
|
|
for row in info :
|
|
|
|
cursor.execute(sql.replace(":values",json.dumps(row)))
|
|
|
|
# self.conn.commit()
|
|
|
|
# print (sql)
|
|
|
|
|