mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 17:34:32 +02:00
35 lines
760 B
Python
35 lines
760 B
Python
from sqlite_utils import Database
|
|
from sqlite_utils.utils import sqlite3
|
|
import pytest
|
|
|
|
CREATE_TABLES = """
|
|
create table Gosh (c1 text, c2 text, c3 text);
|
|
create table Gosh2 (c1 text, c2 text, c3 text);
|
|
"""
|
|
|
|
|
|
@pytest.fixture
|
|
def fresh_db():
|
|
return Database(memory=True)
|
|
|
|
|
|
@pytest.fixture
|
|
def existing_db():
|
|
database = Database(memory=True)
|
|
database.executescript(
|
|
"""
|
|
CREATE TABLE foo (text TEXT);
|
|
INSERT INTO foo (text) values ("one");
|
|
INSERT INTO foo (text) values ("two");
|
|
INSERT INTO foo (text) values ("three");
|
|
"""
|
|
)
|
|
return database
|
|
|
|
|
|
@pytest.fixture
|
|
def db_path(tmpdir):
|
|
path = str(tmpdir / "test.db")
|
|
db = sqlite3.connect(path)
|
|
db.executescript(CREATE_TABLES)
|
|
return path
|