Updating a single field in a custom database

Hi Brian,

I am looking to add and update a specific field (one time) in a custom database and not touch the entire row.

I currently use the below function from quantrocket.db, to only add new data rows to my custom data.

insert_or_ignore(custom_data, 'Price', conn)

However, I need to add a new field and update the data in that field only for all the rows while not changing the other fields because I need to keep certain historical data. Hence I am not using insert_or_replace function.

Is there a way you would recommend for me to accomplish this?

Thanks for your help.

You can open a sqlite shell in the database:

sqlite3 /var/lib/quantrocket/quantrocket.v2.history.my-custom-db.sqlite

Then add the column with the appropriate data type and desired default value. The data type should be DOUBLE for numeric fields:

sqlite> ALTER TABLE Price ADD COLUMN MyNewColumn DOUBLE DEFAULT NULL;
sqlite> .q

Thanks Brian,

So I am also assuming that I can manipulate these databases without worrying about any other metadata maintained by Quantrocket.

That's correct in the case of custom databases.