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

Infrastructure to produce .db files #126

Open
humnaawan opened this issue Jan 25, 2018 · 4 comments
Open

Infrastructure to produce .db files #126

humnaawan opened this issue Jan 25, 2018 · 4 comments

Comments

@humnaawan
Copy link
Contributor

Is there any functionality to save a modified version of the input sqlite database (specifically, e.g., just the Summary table)? I haven't found anything aside from the lsst sims_operations afterburner, which isnt runnable by MAF users. The only way to go about saving a modified .db file is to either get sql queries to work (which I couldn't .. ) or use csv/pandas to do intermediate steps (which probably isnt the best way).

@rhiannonlynne
Copy link
Contributor

Something to save just the summary table, after some stackers have been run to add additional columns? Not really, but I agree it could be useful.
I'm not sure what you mean about getting sql queries to work? Can you explain?

@humnaawan
Copy link
Contributor Author

Yes, so the stackers add columns on the fly but you cant really save the effectively-updated database as a whole. Essentially, what I am thinking is a way to create .db files with modified version of the OpSim database, which can be read like a normal OpSim output.

What I tried to do with sql was to create a copy of the opsim ouput (sqlite_file_copy), read it in, and try to add columns using sql, doing something like:
conn = sqlite3.connect(sqlite_file_copy)
c = conn.cursor()
for i, obsID in enumerate(simdata['obsHistID']): c.execute('UPDATE Summary SET newCol= %s'%(newVal, obsID))
conn.commit()
conn.close()

I tried using executemany but it wasnt doing anything at all and execute was taking too long (as I had to loop over all the obsHistIDs; it was changing values though).

Please let me know if I am not explaining things well.

@rhiannonlynne
Copy link
Contributor

We'll put this on the list as well.
It does raise one issue however, of how to track the provenance for the new information -- the details of how the extra data was added. Also, how to keep track of what version of a database run is what (i.e. if you run a stacker two different times with different parameters and save the output -- which one did your collaborator receive?).

@humnaawan
Copy link
Contributor Author

Great, thank you!

It does raise one issue however, of how to track the provenance for the new information -- the details of how the extra data was added. Also, how to keep track of what version of a database run is what (i.e. if you run a stacker two different times with different parameters and save the output -- which one did your collaborator receive?).

Yeah, that's true. Can we add a table to the sqlite database? I am thinking perhaps something similar to the Summary table, but with version number etc. That way, a summary of the added changes could be required by the user before the new database can be saved?

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

2 participants