mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-07-24 12:53:45 +00:00
ext/python: Basic support for placeholding insert
This commit is contained in:
parent
2481d73d70
commit
16b9325830
3 changed files with 73 additions and 8 deletions
|
@ -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":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue