Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. File "exm0.py", line 14, in <module>
  2. cursor.execute("""INSERT INTO Employee VALUES({0}, {1})""".format(k, v))
  3. sqlite3.OperationalError: no such column: dani
  4.  
  5. from user_names import *
  6. import sqlite3
  7.  
  8. # user_names.py
  9. names = ["dani", "eric", "dinna", "tamir", "edan", "daniel", "tomer",
  10. "noa", "shalev", "tom", "shir"]
  11. phones = ["0432", "5415166255", "61467254", "6146758", "5889482"]
  12.  
  13. connection = sqlite3.connect("")
  14. cursor = connection.cursor()
  15.  
  16.  
  17. cursor.execute("""CREATE TABLE Employee(Name text, Phone int)""")
  18. acc = {}
  19.  
  20. for k, v in zip(names, phones):
  21. #acc[k] = v
  22. cursor.execute("""INSERT INTO Employee VALUES({0},
  23. {1})""".format(k, v))
  24.  
  25. for k, v in zip(names, phones):
  26. #acc[k] = v
  27. cursor.execute("INSERT INTO Employee VALUES(?, ?)", (k, v))
  28.  
  29. cursor.executemany("INSERT INTO Employee VALUES(?, ?)", zip(names, phones))
  30.  
  31. for k, v in zip(names, phones):
  32. #acc[k] = v
  33. cursor.execute("INSERT INTO Employee (Name, Phone) VALUES(?,?)", (k, v))
  34.  
  35. cursor.execute("INSERT INTO Employee VALUES(?, ?)", [k, v])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement