|
3 | 3 |
|
4 | 4 | import sys |
5 | 5 |
|
| 6 | +import httpx |
| 7 | + |
6 | 8 | import ldlite |
7 | 9 |
|
8 | 10 | # Demo sites |
|
30 | 32 | ) |
31 | 33 |
|
32 | 34 | ld.connect_db(filename="ldlite.db") |
33 | | -# For PostgreSQL, use connect_db_postgresql() instead of connect_db(): |
| 35 | +# For PostgreSQL, use connect_db_postgresql() instead: |
34 | 36 | # ld.connect_db_postgresql(dsn='dbname=ldlite host=localhost user=ldlite') |
35 | 37 |
|
36 | 38 | queries: list[tuple[str, ...] | tuple[str, str, object, int]] = [ |
37 | 39 | ("folio_agreements.entitlement", "/erm/entitlements"), |
38 | 40 | ("folio_agreements.erm_resource", "/erm/resource"), |
39 | 41 | ("folio_agreements.org", "/erm/org"), |
40 | 42 | ("folio_agreements.refdata_value", "/erm/refdata"), |
41 | | - ("folio_agreements.usage_data_provider", "/usage-data-providers"), |
| 43 | + # This endpoint doesn't work in EBSCO environments |
| 44 | + # ("folio_agreements.usage_data_provider", "/usage-data-providers"), |
42 | 45 | ("folio_audit.circulation_logs", "/audit-data/circulation/logs"), |
43 | 46 | ("folio_circulation.audit_loan", "/loan-storage/loan-history"), |
44 | 47 | ( |
|
165 | 168 | "/acquisitions-units-storage/memberships", |
166 | 169 | ), |
167 | 170 | ("folio_orders.alert", "/orders-storage/alerts"), |
168 | | - ("folio_orders.order_invoice_relationship/orders-storage/order-invoice-relns"), |
| 171 | + ("folio_orders.order_invoice_relationship", "/orders-storage/order-invoice-relns"), |
169 | 172 | ("folio_orders.order_templates", "/orders-storage/order-templates"), |
170 | 173 | ("folio_orders.pieces", "/orders-storage/pieces"), |
171 | 174 | ("folio_orders.po_line", "/orders-storage/po-lines"), |
|
176 | 179 | ("folio_organizations.contacts", "/organizations-storage/contacts"), |
177 | 180 | ("folio_organizations.emails", "/organizations-storage/emails"), |
178 | 181 | ("folio_organizations.interfaces", "/organizations-storage/interfaces"), |
179 | | - ("folio_organizations.organizations", "/organizations-storage/organizations"), |
| 182 | + ("folio_organizations.organizations", "/organizations/organizations"), |
180 | 183 | ("folio_organizations.phone_numbers", "/organizations-storage/phone-numbers"), |
181 | 184 | ("folio_organizations.urls", "/organizations-storage/urls"), |
182 | | - ("folio_source_record.records", "/source-storage/records", {}, 2), |
| 185 | + ("folio_source_record.records", "/source-storage/records", 2), |
183 | 186 | ("folio_users.addresstype", "/addresstypes"), |
184 | 187 | ("folio_users.departments", "/departments"), |
185 | 188 | ("folio_users.groups", "/groups"), |
186 | 189 | ("folio_users.proxyfor", "/proxiesfor"), |
187 | 190 | ("folio_users.users", "/users"), |
188 | 191 | ] |
189 | 192 |
|
| 193 | +errors: list[tuple[str, BaseException]] = [] |
190 | 194 | tables: list[str] = [] |
191 | 195 | for q in queries: |
192 | 196 | try: |
193 | | - if len(q) == 4: |
| 197 | + if len(q) == 3: |
194 | 198 | tables += ld.query( |
195 | 199 | table=q[0], |
196 | 200 | path=q[1], |
197 | | - query=str(q[2]), |
198 | | - json_depth=int(q[3]), |
| 201 | + json_depth=int(q[2]), |
199 | 202 | ) |
200 | 203 | else: |
201 | | - tables += ld.query(table=q[0], path=q[1], query=str(q[2])) |
202 | | - except (ValueError, RuntimeError) as e: |
203 | | - print( |
204 | | - 'folio_demo.py: error processing "' + str(q[1]) + '": ' + str(e), |
205 | | - file=sys.stderr, |
206 | | - ) |
| 204 | + tables += ld.query(table=q[0], path=q[1]) |
| 205 | + except (ValueError, RuntimeError, httpx.HTTPError) as e: |
| 206 | + errors += [(q[1], e)] |
207 | 207 | print() |
208 | 208 | print("Tables:") |
209 | 209 | for t in tables: |
210 | 210 | print(t) |
211 | 211 | print("(" + str(len(tables)) + " tables)") |
| 212 | +if len(errors) > 0: |
| 213 | + print() |
| 214 | + print("Errors:") |
| 215 | + for p, e in errors: |
| 216 | + print( |
| 217 | + 'folio_demo.py: error processing "' + p + '": ' + str(e), |
| 218 | + file=sys.stderr, |
| 219 | + ) |
| 220 | +print("(" + str(len(errors)) + " errors)") |
0 commit comments