Guest User

Untitled

a guest
Dec 9th, 2019
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import duckdb
  2.  
  3. create_docs = """ CREATE TABLE docs (
  4. trecid VARCHAR,
  5. luceneid INTEGER,
  6. length VARCHAR,
  7. irr INTEGER
  8. );
  9. """
  10.  
  11. create_dict = """ CREATE TABLE dict (
  12. termid INTEGER,
  13. term VARCHAR,
  14. df INTEGER
  15. );
  16. """
  17.  
  18. create_terms = """CREATE TABLE terms (
  19. termid INTEGER,
  20. luceneid INTEGER,
  21. count INTEGER
  22. );
  23. """
  24.  
  25. copy_docs = """ COPY docs
  26. FROM '/Users/Daan/IdeaProjects/docs.csv'
  27. WITH (DELIMITER '|')
  28. """
  29.  
  30. copy_dict = """ COPY dict
  31. FROM '/Users/Daan/IdeaProjects/dict.csv'
  32. WITH (DELIMITER '|')
  33. """
  34.  
  35. copy_terms = """ COPY terms
  36. FROM '/Users/Daan/IdeaProjects/terms.csv'
  37. WITH (DELIMITER '|')
  38. """
  39.  
  40. test_statement = "INSERT INTO terms VALUES (10, 20, 30);"
  41.  
  42. cursor = duckdb.connect(':memory:').cursor()
  43. cursor.execute(create_dict)
  44. cursor.execute(create_docs)
  45. cursor.execute(create_terms)
  46. cursor.execute(copy_docs)
  47. cursor.execute(copy_dict)
  48. cursor.execute(copy_terms)
  49. cursor.execute("ALTER TABLE docs DROP irr")
  50. print(cursor.execute("SELECT * FROM docs WHERE luceneid = 595036").fetchall())
RAW Paste Data