-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathagree_load.py
More file actions
48 lines (42 loc) · 1.29 KB
/
agree_load.py
File metadata and controls
48 lines (42 loc) · 1.29 KB
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
43
44
45
46
47
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 = [
('agreements.entitlement', '/erm/entitlements'),
# ('agreements.erm_resource', '/erm/resource'),
('agreements.org', '/erm/org'),
('agreements.refdata_value', '/erm/refdata'),
('agreements.sas', '/erm/sas', 2),
# ('agreements.usage_data_provider', '/usage-data-providers'),
# ('finance.fund_code_exp_cla', '/finance/fund-codes-expense-classes'),
]
tables = []
for q in queries:
try:
if len(q) == 3:
t = ld.query(table=q[0], path=q[1], json_depth=q[2], keep_raw=False)
else:
t = ld.query(table=q[0], path=q[1], keep_raw=False)
tables += t
except Exception as ex:
print('folio_demo.py: error processing "' + q[1] + '"', file=sys.stderr)
print(ex, file=sys.stderr)
print()
print('Tables:')
for t in tables:
print(t)
print('(' + str(len(tables)) + ' tables)')