aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/py/lib/db.py
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2023-12-28 01:00:45 +0100
committerEgor Tensin <egor@tensin.name>2023-12-28 01:00:45 +0100
commita9ae33c4b9dbe566d2ada07affb8b5a135f9b6eb (patch)
tree72b47c96da722d5e034af789f4af432e3fdfa051 /test/py/lib/db.py
parentjson: factor out json_object_put into json_free (diff)
downloadcimple-a9ae33c4b9dbe566d2ada07affb8b5a135f9b6eb.tar.gz
cimple-a9ae33c4b9dbe566d2ada07affb8b5a135f9b6eb.zip
test/py/ -> test/src/
Diffstat (limited to 'test/py/lib/db.py')
-rw-r--r--test/py/lib/db.py30
1 files changed, 0 insertions, 30 deletions
diff --git a/test/py/lib/db.py b/test/py/lib/db.py
deleted file mode 100644
index de6960a..0000000
--- a/test/py/lib/db.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (c) 2023 Egor Tensin <egor@tensin.name>
-# This file is part of the "cimple" project.
-# For details, see https://github.com/egor-tensin/cimple.
-# Distributed under the MIT License.
-
-from contextlib import closing, contextmanager
-import logging
-import sqlite3
-
-
-class Database:
- def __init__(self, path):
- logging.info('Opening SQLite database: %s', path)
- self.conn = sqlite3.connect(f'file:{path}?mode=ro', uri=True)
-
- def __enter__(self):
- return self
-
- def __exit__(*args):
- self.conn.close()
-
- @contextmanager
- def get_cursor(self):
- with closing(self.conn.cursor()) as cur:
- yield cur
-
- def get_all_runs(self):
- with self.get_cursor() as cur:
- cur.execute('SELECT * FROM cimple_runs_view')
- return cur.fetchall()