Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace lookup table ids with name #34

Open
hover2pi opened this issue Mar 29, 2018 · 1 comment
Open

Replace lookup table ids with name #34

hover2pi opened this issue Mar 29, 2018 · 1 comment

Comments

@hover2pi
Copy link
Contributor

Instead of displaying telescope_id=1 for a photometry record, replace it with telescopes.name so that it says telescope_id=HST

@hover2pi
Copy link
Contributor Author

hover2pi commented Mar 30, 2018

Perhaps make a set of VIEWS like so:

for table in db.query("select name from sqlite_master where type='table'")['name']:
    colnames = db.query("pragma table_info('{}')".format(table))['name']
    view = "CREATE VIEW {0}_ AS SELECT {1} from {0}".format(table,','.join(colnames))
    for col in ['telescope_id','system_id','mode_id','instrument_id']:
        tab = col.split('_')[0]
        query = "(SELECT name FROM {0}s WHERE id={1}.{2}) as {0}".format(tab,table,col)
        view = view.replace(col,query)
    print(view)

Then query in the normal fashion:

SELECT * FROM photometry_ WHERE band='WISE.W1'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant