Advertisement
Nikoh77

Untitled

Dec 3rd, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def definition():
  2.     import sqlite3
  3.     global db
  4.     global cursor
  5.     global dbpath
  6.     dbpath = "/home/nikoh/PycharmProjects/gestionale/db/HME.db"
  7.     db = sqlite3.connect(dbpath)
  8.     cursor = db.cursor()
  9.  
  10.  
  11. def insert(tablename, posted):
  12.     definition()
  13.     keys = list(posted.keys())
  14.     values = list(posted.values())
  15.     keys = str(keys)[1:-1]
  16.     with db:
  17.         cursor.execute("INSERT INTO "+tablename+"("+keys+")"+" VALUES(?, ?, ?)", values)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement