-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsrc_download.py
More file actions
39 lines (33 loc) · 906 Bytes
/
src_download.py
File metadata and controls
39 lines (33 loc) · 906 Bytes
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
import os
import sys
import ldlite
ld = ldlite.LDLite()
ld.connect_folio(
url=os.environ['FOLIOURL'],
tenant=os.environ['FOLIOTENANT'],
user=os.environ['FOLIOUSER'],
password=os.environ['FOLIOPASSWORD'],
)
db = ld.connect_db_postgresql(dsn=f"""
dbname={os.environ['PGDATABASE']}
host={os.environ['PGHOST']}
port={os.environ['PGPORT']}
user={os.environ['PGUSER']}
password={os.environ['PGPASSWORD']}
""")
queries = [
('folio_source_record.records', '/source-storage/source-records')
]
tables = []
for q in queries:
try:
t = ld.query(table=q[0], path=q[1], json_depth=2, keep_raw=False)
tables += t
except Exception as e:
print('folio_src.py: error processing "' + q[1] + '"', file=sys.stderr)
print(e, file=sys.stderr)
print()
print('Tables:')
for t in tables:
print(t)
print('(' + str(len(tables)) + ' tables)')