astropy / astropy/pyvo

Enumerate tables from a TAP service by schema?

Open
#203 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
88
Forks
64
Avg merge
38m
Merged PRs (30d)
1

Description

Is it possible to get at schema information for a table when enumerating tables via TAPService? I have only been able to get schema information via `tap_service.tables._vosi_tables.tableset.schemas` (see full example below). I worry I am missing something obvious.

In the endpoint I'm accessing the table names always begin with the schema, so I can
just do this via string manipulation, but I'm not sure if this is always the case.

```
import pyvo as vo

def print_column_information(column):
print("Name:", column.name)
print("Description:", column.description)
print("Unit:", column.unit)
print("Datatype:", column.datatype.content)

def print_table_information(table, print_columns=False):
# This doesn't work:
# print("Schema:", table.schema)
print("Table:", table.name, table.type, table.utype)
print("Table description:", table.description)
if print_columns:
for column in table.columns:
print_column_information(column)

tap_service = vo.dal.TAPService("http://vao.stsci.edu/zmast/tapservice.aspx")

# Can get to schemas via internal _vosi_tables member, but this seems like a hack
for schema in tap_service.tables._vosi_tables.tableset.schemas:
if schema.name != "dbo":
continue
print("Schema:", schema.name, type(schema))
for table in schema:
print_table_information(table)

# Can get to tables like this, but tables seem schema-unaware
for table in tap_service.tables:
print_table_information(table)

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by examining the public TAPService.tables iteration and the private tap_service.tables._vosi_tables.tableset.schemas path shown in the example. Determine whether schema-aware table enumeration is supported or needs an API change, and define completion as obtaining each table's schema without relying on the private member.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.