fork download
  1. import sqlite3
  2.  
  3. print(sqlite3.version, sqlite3.sqlite_version)
  4.  
  5. con = sqlite3.connect(":memory:")
  6. c = con.cursor()
  7.  
  8. c.execute("create table jjo_errors (id integer primary key, name varchar(100))")
  9. c.execute("create table tasks (id integer primary key, name varchar(100))")
  10. c.execute("""create table connections_to_jjos (
  11. connections_id integer,
  12. jjo_error_id integer,
  13. binder_task_id integer)""")
  14.  
  15. c.execute("insert into jjo_errors values (1, 'known'), (2, '--Unknown--')")
  16. c.execute("insert into tasks values (3, 'DCDD'), (4, 'ANDD')")
  17.  
  18. q = """
  19. INSERT INTO connections_to_jjos(
  20. connections_id,
  21. jjo_error_id,
  22. binder_task_id
  23. )
  24. VALUES
  25.  
  26. (
  27. 55,
  28. (select id from jjo_errors where name = "--Unknown--"),
  29. (select id from tasks where name = "DCDD")
  30. )
  31. ,
  32.  
  33. (
  34. 55,
  35. (select id from jjo_errors where name = "--Unknown--"),
  36. (select id from tasks where name = "ANDD")
  37. )
  38. """
  39. c.execute(q)
  40. c.execute('select * from connections_to_jjos')
  41. print(c.fetchall())
  42.  
  43. c.execute("insert into jjo_errors values (5, 'known'), (6, '--Unknown--')")
  44. c.execute("insert into tasks values (7, 'something'), (8, 'ANDD')")
  45.  
  46. c.execute(q)
  47. c.execute('select * from connections_to_jjos')
  48. print(c.fetchall())
  49.  
Runtime error #stdin #stdout #stderr 0.09s 12384KB
stdin
Standard input is empty
stdout
2.6.0 3.7.3
stderr
Traceback (most recent call last):
  File "prog.py", line 15, in <module>
    c.execute("insert into jjo_errors values (1, 'known'), (2, '--Unknown--')")
sqlite3.OperationalError: near ",": syntax error