Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

openlib.py 1.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  1. from invoke import task
  2. import support as s
  3. @task
  4. def init(c):
  5. "Initialize the OpenLibrary schema"
  6. print('initializing OpenLibrary schema')
  7. c.run('psql -f ol-schema.sql')
  8. @task(s.build)
  9. def import_authors(c, date='2018-10-31'):
  10. "Import OpenLibrary authors"
  11. infile = s.data_dir / f'ol_dump_authors_{date}.txt.gz'
  12. s.pipeline([
  13. [s.bin_dir / 'clean-json', '--openlib', infile],
  14. ['psql', '-c', '\\copy ol_author (author_key, author_data) FROM STDIN']
  15. ])
  16. @task(s.build)
  17. def import_editions(c, date='2018-10-31'):
  18. "Import OpenLibrary editions"
  19. infile = s.data_dir / f'ol_dump_editions_{date}.txt.gz'
  20. s.pipeline([
  21. [s.bin_dir / 'clean-json', '--openlib', infile],
  22. ['psql', '-c', '\\copy ol_edition (edition_key, edition_data) FROM STDIN']
  23. ])
  24. @task(s.build)
  25. def import_works(c, date='2018-10-31'):
  26. "Import OpenLibrary works"
  27. infile = s.data_dir / f'ol_dump_works_{date}.txt.gz'
  28. s.pipeline([
  29. [s.bin_dir / 'clean-json', '--openlib', infile],
  30. ['psql', '-c', '\\copy ol_work (work_key, work_data) FROM STDIN']
  31. ])
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...