This is a collection of tricks, commands and SQL queries that you might find helpful.
### Exporting JSON to file ###
If you saved JSON data to the database in compressed format (`store_raw_json=true` and `json_store_mode=xz`) you can export them to separate files with the following bash command (assuming current directory contains a originsro.db3 DB):
done <<(sqlite3 ../debug/originsro.db3 'select source from source_store where format=2')
```
This will not export plain uncompressed JSON (`format=1`)
### Getting min/max price of each item on the market now ###
With this query you can retrieve the min and max price of each item currently being sold (assuming database is up to date), along with their names, the name of the shop selling them and the total count of items of that type across all shops and all prices. Note that refined equipment or equipment with cards are considered to be all equivalent to the plain item.
```
SELECT title, name, MIN(price) AS min_price, MAX(price) AS max_price, SUM(amount) AS amount FROM (
"Currently open" means shops seen on the same date the most recent shop was seen. In my current case my database was last updated 6 hours ago, this means I'm seeing the list of items that were being sold 6 hours ago.
### Estimate JSON storage size ###
This returns an estimate in MiB of the total storage occupied by the saved JSON data
```
SELECT SUM(LENGTH(source))/1024/1024 FROM source_store