mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-07-24 12:53:45 +00:00
ext/python: Add support for Context Manager
This commit is contained in:
parent
6798341b05
commit
4ca5b11bed
2 changed files with 24 additions and 0 deletions
|
@ -144,6 +144,17 @@ def test_commit(provider):
|
|||
conn.close()
|
||||
assert record
|
||||
|
||||
@pytest.mark.parametrize("provider", ["sqlite3", "limbo"])
|
||||
def test_with_statement(provider):
|
||||
with connect(provider, "tests/database.db") as conn:
|
||||
conn = connect(provider, "tests/database.db")
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT MAX(id) FROM users")
|
||||
|
||||
max_id = cursor.fetchone()
|
||||
|
||||
assert max_id
|
||||
assert max_id == (2,)
|
||||
|
||||
def connect(provider, database):
|
||||
if provider == "limbo":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue