Advertisement
Carcigenicate

D of D storer

May 24th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def save_dict (dic):
  2.     for keyword,subdic in dic.items():
  3.         try:
  4.             with conn:
  5.                 #print("\'{}\'".format(keyword))
  6.                 cur.execute('CREATE TABLE IF NOT EXISTS [{}] (word TEXT,value INT, unique(word));'.format(keyword))
  7.         except db.OperationalError as oe:
  8.                 print("OperationalError:",oe)
  9.         for word,value in subdic.items():
  10.             try:
  11.                 with conn:
  12.                     cur.execute('INSERT INTO [{}] VALUES (?,?);'.format(keyword),(word,value))
  13.             except db.IntegrityError as ie:
  14.                 pass#print("Integrity error:",ie)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement