Commit Graph

5 Commits

Author SHA1 Message Date
Anna Schumaker 7e6f944cde gc: Vacuum the database after garbage collecting
This patch adds a "vacuum()" function to our sqlite Connection that is
called if we detect that rows have been deleted during `xfstestsdb gc`

Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
2023-11-07 15:02:35 -05:00
Anna Schumaker 2082b904a0 sqlite: Add an upgrade script to database version 2
Right now it doesn't do any extra changes to the database besides
bumping the user_version to '2'. I'll fill it out over the next several
commits.

Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
2023-07-25 10:03:32 -04:00
Anna Schumaker 3f61adc941 sqlite: Give the Connection an executescript() function
This function builds on the built-in Python function, and adds in
opening and reading the file in a way that can be used for running
generic scripts on the database.

I also take this chance to move SQL scripts into a subdirectory to keep
them together.

Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
2023-07-25 09:54:31 -04:00
Anna Schumaker 5d141bd436 sqlite: Make sure foreign_keys are enabled
SQLite wants foreign_keys to be enabled for each connection, and doesn't
save this setting.

Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
2023-04-17 15:57:47 -04:00
Anna Schumaker 929c1dd5eb xfstestsdb: Create a custom sqlite3 Connection manager
The connection manager is used to initialize the database and has a
wrapper around the sqlite3.execute() and sqlite3.executemany() functions
for easier argument passing.

Additionally, it implements __enter__() and __exit__() functions to
manually begin a transaction to calls can use the sqlite3 "RETURNING"
clause.

Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
2023-02-15 11:52:41 -05:00