mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-03 09:42:22 +00:00
ext/python: Makes linter happy
This commit is contained in:
parent
9a8970b6a8
commit
6edf3dd3b1
2 changed files with 14 additions and 9 deletions
|
@ -15,16 +15,19 @@ with limbo.connect("sqlite.db") as con:
|
||||||
|
|
||||||
# Insert some sample data
|
# Insert some sample data
|
||||||
sample_users = [
|
sample_users = [
|
||||||
("alice", "alice@example.com", "admin"),
|
("alice", "alice@example.com", "admin"),
|
||||||
("bob", "bob@example.com", "user"),
|
("bob", "bob@example.com", "user"),
|
||||||
("charlie", "charlie@example.com", "moderator"),
|
("charlie", "charlie@example.com", "moderator"),
|
||||||
("diana", "diana@example.com", "user")
|
("diana", "diana@example.com", "user"),
|
||||||
]
|
]
|
||||||
for username, email, role in sample_users:
|
for username, email, role in sample_users:
|
||||||
cur.execute("""
|
cur.execute(
|
||||||
|
"""
|
||||||
INSERT INTO users (username, email, role)
|
INSERT INTO users (username, email, role)
|
||||||
VALUES (?, ?, ?)
|
VALUES (?, ?, ?)
|
||||||
""", (username, email, role))
|
""",
|
||||||
|
(username, email, role),
|
||||||
|
)
|
||||||
|
|
||||||
# Use commit to ensure the data is saved
|
# Use commit to ensure the data is saved
|
||||||
con.commit()
|
con.commit()
|
||||||
|
|
|
@ -144,18 +144,20 @@ def test_commit(provider):
|
||||||
conn.close()
|
conn.close()
|
||||||
assert record
|
assert record
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("provider", ["sqlite3", "limbo"])
|
@pytest.mark.parametrize("provider", ["sqlite3", "limbo"])
|
||||||
def test_with_statement(provider):
|
def test_with_statement(provider):
|
||||||
with connect(provider, "tests/database.db") as conn:
|
with connect(provider, "tests/database.db") as conn:
|
||||||
conn = connect(provider, "tests/database.db")
|
conn = connect(provider, "tests/database.db")
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("SELECT MAX(id) FROM users")
|
cursor.execute("SELECT MAX(id) FROM users")
|
||||||
|
|
||||||
max_id = cursor.fetchone()
|
max_id = cursor.fetchone()
|
||||||
|
|
||||||
assert max_id
|
assert max_id
|
||||||
assert max_id == (2,)
|
assert max_id == (2,)
|
||||||
|
|
||||||
|
|
||||||
def connect(provider, database):
|
def connect(provider, database):
|
||||||
if provider == "limbo":
|
if provider == "limbo":
|
||||||
return limbo.connect(database)
|
return limbo.connect(database)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue