Project TouCans just got a major database upgrade! The QSO records that KO6BTY and I log from field activations can now be appended directly from our GitHub CSV files instead of regenerating the entire SQLite database. This new method—based on an approach I first saw in Simon Willison’s video—keeps local data editable while automatically merging in the latest contacts from the cloud.
The project code is here.
The excellent video by Simon Willison that inspired this methodology is here.
Finally, here's more background on Project TouCans.
The Setup
I've written a qso database that KO6BTY and I use to track our QSOs. Over time, we've built various ionospheric analysis apps with Datasette that work with and add to the data.
The Problem
I had to create the rm_toucans.db sqlite file from a csv file stored on github. Each time, the old rm_toucans.db was thrown out and an entirely new database file was generated. With that methdology the records in rm_toucans.db were not editable.
At first this was ok, but more and more of our analysis tools are editing rm_toucans.db records. The simplest example involves calculating the launch angle of a transmitted signal. It's computationally intense and the result, once calculated, never changes. Rather than calculate it more than once, we want to be able to just store the result in the qso database along with the rest of the information for that QSO. I lose those record edits with the original methodology.
The Solution
I created a Python script that accepts a timestamp as an argument. It then reads the csv file inserting records that are after that date to the sqlite database. All the modified records remain in the database. That script can be found here. Here's the documentation.
What's Next
Simply open the sqlqite database and run a query to find the latest date without user input.
This also allows other apps like:
When the height of a QSO transmit location is adjusted, store it in the slice database along with a field height_adjust = 1. Then, use a second script to copy that modified record back over to the original rm_toucans.db. Do the same thing for launch angle and hmF2 per QSO. In that way, I'll get rid of the multiple step process for updating those fields at the moment. (Note: there currently is no process at all for updating the tx location altitude in the database.)
Comments
Post a Comment
Please leave your comments on this topic: