ext/python: Basic support for placeholding insert

This commit is contained in:
Diego Reis 2025-03-20 17:05:39 -03:00
parent 2481d73d70
commit 16b9325830
3 changed files with 73 additions and 8 deletions

View file

@ -66,6 +66,40 @@ def test_fetchone_select_max_user_id(provider):
assert max_id
assert max_id == (2,)
# Test case for: https://github.com/tursodatabase/limbo/issues/494
@pytest.mark.parametrize("provider", ["sqlite3", "limbo"])
def test_commit(provider):
con = limbo.connect("sqlite.db")
cur = con.cursor()
cur.execute("""
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
email TEXT NOT NULL,
role TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT (datetime('now'))
)
""")
con.commit()
sample_users = [
("alice", "alice@example.com", "admin"),
("bob", "bob@example.com", "user"),
("charlie", "charlie@example.com", "moderator"),
("diana", "diana@example.com", "user")
]
for username, email, role in sample_users:
cur.execute("INSERT INTO users (username, email, role) VALUES (?, ?, ?)", (username, email, role))
con.commit()
# Now query the table
res = cur.execute("SELECT * FROM users")
record = res.fetchone()
assert record
def connect(provider, database):
if provider == "limbo":