| 1 | """ |
| 2 | Handling table metadata in the dc.(table|column)meta tables. |
| 3 | |
| 4 | This has been a mediocre plan, and it's almost unused these days except |
| 5 | to locate RDs for tables. Hence, we should tear this entire thing down |
| 6 | and have the table->RD mapping stowed somewhere else. |
| 7 | |
| 8 | Or at least give up on the extra connection and have the clients use |
| 9 | base.getTableDefForTable(connection, tableName) directly. |
| 10 | """ |
| 11 | |
| 12 | #c Copyright 2008-2025, the GAVO project <[email protected]> |
| 13 | #c |
| 14 | #c This program is free software, covered by the GNU GPL. See the |
| 15 | #c COPYING file in the source distribution. |
| 16 | |
| 17 | |
| 18 | from gavoscip-python python gavodachs 2.13 gavo/__init__: import basescip-python python gavodachs 2.13 `gavo.base`/__init__: |
| 19 | |
| 20 | |
| 21 | class MetaTableHandlerscip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#: |
| 22 | """an interface to DaCHS meta tables. |
| 23 | |
| 24 | This used to be a fairly complex interface to all sorts for DC-related |
| 25 | metadata. These day, the only thing it does is figure out where |
| 26 | table definitions reside and which are available for ADQL. This thing |
| 27 | has been a bad idea all around. |
| 28 | |
| 29 | Though you can construct MetaTableHandlers of your own, you should |
| 30 | use base.caches.getMTH(None) when reading. |
| 31 | """ |
| 32 | def __init__scip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#__init__().(selfscip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#__init__().(self)): |
| 33 | selfscip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#__init__().(self).rdscip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#rd. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.cachesscip-python python gavodachs 2.13 `gavo.base.caches`/__init__:.getRD("__system__/dc_tables") |
| 34 | |
| 35 | def getTableDefForTablescip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#getTableDefForTable().(selfscip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#getTableDefForTable().(self), tableNamescip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#getTableDefForTable().(tableName)): |
| 36 | """returns a TableDef for tableName. |
| 37 | |
| 38 | As it is not a priori clear which RD a given table lives in, |
| 39 | this goes through dc.tablemeta to figure this out. The |
| 40 | object comes from the actual RD, though, so this might very well |
| 41 | trigger database action and RD loading. |
| 42 | """ |
| 43 | with basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getTableConnscip-python python gavodachs 2.13 `gavo.base.sqlsupport`/getTableConn.() as conn: |
| 44 | return basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getTableDefForTablescip-python python gavodachs 2.13 `gavo.base.parsecontext`/getTableDefForTable().(conn, tableNamescip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#getTableDefForTable().(tableName)) |
| 45 | |
| 46 | def getTAPTablesscip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#getTAPTables().(selfscip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#getTAPTables().(self)): |
| 47 | """returns a list of all names of tables accessible through TAP in |
| 48 | this data center. |
| 49 | """ |
| 50 | with basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getTableConnscip-python python gavodachs 2.13 `gavo.base.sqlsupport`/getTableConn.() as conn: |
| 51 | return [r["tablename"] for r in |
| 52 | conn.queryToDictsscip-python python gavodachs 2.13 `gavo.base.sqlsupport`/DaCHSConnection#queryToDicts().( |
| 53 | "select tablename from dc.tablemeta where adql")] |
| 54 | |
| 55 | |
| 56 | def _getMetaTablescip-python python gavodachs 2.13 `gavo.rsc.metatable`/_getMetaTable().(ignoredscip-python python gavodachs 2.13 `gavo.rsc.metatable`/_getMetaTable().(ignored)): |
| 57 | return MetaTableHandlerscip-python python gavodachs 2.13 `gavo.rsc.metatable`/MetaTableHandler#() |
| 58 | |
| 59 | basescip-python python gavodachs 2.13 `gavo.base`/__init__:.cachesscip-python python gavodachs 2.13 `gavo.base.caches`/__init__:.makeCachescip-python python gavodachs 2.13 `gavo.base.caches`/makeCache().("getMTH", _getMetaTablescip-python python gavodachs 2.13 `gavo.rsc.metatable`/_getMetaTable().) |