Show Records#

Note

The show_ endpoints are meant to be used by admins to build functionality into their metacatalog deployment. These endpoints are not really helpful for the end-user.

Help#

metacatalog.api.show_records(session, table_name, limit=None, where=None, as_dict=True)#

Returns a list or dictionary of raw table contents in the database.

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • table_name (str) – Name of the table the records are requested for.

  • limit (int) – Positive integer to limit the requested data. If None, no limit will be set

  • where (str) – Possible raw SQL WHERE clause. If None, the output will not be filtered.

  • as_dict (bool) – If True, each records will be returned as a dict, else as a tuple with the columns ordered as defined in the Model

Returns:

records – List of dicts or tuples representing the records.

Return type:

list

Example#

Note

This endpoint is not meant to be used to load metadata from the database in a production scenario. You can use it for backups or during development. It will return the raw table contents. To actually use the metadata, use the metacatalog.models classes or the api.find_* endpoints.

[1]:
from metacatalog import api

session = api.connect_database()
[3]:
api.show_records(session, table_name='entries', limit=10)
[3]:
[{'id': 1,
  'title': 'Sap Flow - Hohes Holz - Tree 022',
  'abstract': 'Sap flow tree 022- 20mm- east',
  'external_id': '212',
  'location': '01010000006806F1811D0B4A4002452C62D8712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'not yet converted',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 1,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 712110),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 712195),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 540713)},
 {'id': 2,
  'title': 'Sap Flow - Hohes Holz - Tree 022',
  'abstract': 'Sap flow tree 022- 20mm- north-west',
  'external_id': '214',
  'location': '01010000006806F1811D0B4A4002452C62D8712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'not yet converted',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 2,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 749350),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 749407),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 565270)},
 {'id': 3,
  'title': 'Sap Flow - Hohes Holz - Tree 029',
  'abstract': 'Sap flow tree 029- 20mm- north',
  'external_id': '246',
  'location': '0101000000761C3F541A0B4A4099F04BFDBC712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'not yet converted',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 3,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 770584),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 770633),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 576064)},
 {'id': 4,
  'title': 'Sap Flow - Hohes Holz - Tree 048',
  'abstract': 'Sap flow tree 048- 20mm- north 2015',
  'external_id': '269',
  'location': '01010000008BA8893E1F0B4A400B24287E8C712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'nan',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 4,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 789248),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 789294),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 587474)},
 {'id': 5,
  'title': 'Sap Flow - Hohes Holz - Tree 050',
  'abstract': 'Sap flow tree 050- 20mm- east',
  'external_id': '275',
  'location': '0101000000C11DA8531E0B4A404A26A77686712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'nan',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 5,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 807256),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 807302),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 598154)},
 {'id': 6,
  'title': 'Sap Flow - Hohes Holz - Tree 056',
  'abstract': 'Sap flow tree 056- 20mm- north',
  'external_id': '282',
  'location': '01010000003FA7203F1B0B4A4036E50AEF72712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'nan',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 6,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 825347),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 825393),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 608043)},
 {'id': 7,
  'title': 'Sap Flow - Hohes Holz - Tree 057',
  'abstract': 'Sap flow tree 057- 20mm- north',
  'external_id': '292',
  'location': '01010000009335EA211A0B4A40D6743DD175712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'nan',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 7,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 844292),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 844339),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 618236)},
 {'id': 8,
  'title': 'Sap Flow - Hohes Holz - Tree 058',
  'abstract': 'Sap flow tree 058- 20mm- east-north-east',
  'external_id': '306',
  'location': '0101000000A46C91B41B0B4A40807EDFBF79712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'nan',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 8,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 863693),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 863740),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 627976)},
 {'id': 9,
  'title': 'Sap Flow - Hohes Holz - Tree 106',
  'abstract': 'Sap flow tree 106 - 20mm - east - commertial',
  'external_id': '326',
  'location': '0101000000A87004A9140B4A40B79C4B7155712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'commertial sensor in 20mm depth',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 9,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 884135),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 884185),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 637880)},
 {'id': 10,
  'title': 'Sap Flow - Hohes Holz - Tree 108',
  'abstract': 'Sap flow tree 108 - 20mm - east-north-east - commertial',
  'external_id': '333',
  'location': '0101000000D828EB37130B4A403C855CA967712640',
  'geom': None,
  'creation': None,
  'end': None,
  'version': 1,
  'latest_version_id': None,
  'comment': 'commertial sensor in 20mm depth',
  'license_id': 2,
  'variable_id': 14,
  'datasource_id': 10,
  'embargo': True,
  'embargo_end': datetime.datetime(2022, 5, 15, 12, 43, 57, 904529),
  'publication': datetime.datetime(2020, 5, 15, 12, 43, 57, 904578),
  'lastUpdate': datetime.datetime(2020, 5, 15, 13, 17, 47, 647861)}]