mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 18:04:32 +02:00
Support Database(memory=True) for in-memory databases
This commit is contained in:
parent
58db40d67c
commit
034d498b31
4 changed files with 25 additions and 6 deletions
|
|
@ -1,16 +1,15 @@
|
|||
from sqlite_utils import Database
|
||||
from sqlite_utils.utils import sqlite3
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fresh_db():
|
||||
return Database(sqlite3.connect(":memory:"))
|
||||
return Database(memory=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def existing_db():
|
||||
database = Database(sqlite3.connect(":memory:"))
|
||||
database = Database(memory=True)
|
||||
database.conn.executescript(
|
||||
"""
|
||||
CREATE TABLE foo (text TEXT);
|
||||
|
|
|
|||
|
|
@ -727,3 +727,10 @@ def test_create_table_numpy(fresh_db):
|
|||
"np.uint8": 8,
|
||||
}
|
||||
] == list(fresh_db["types"].rows)
|
||||
|
||||
|
||||
def test_cannot_provide_both_filename_and_memory():
|
||||
with pytest.raises(
|
||||
AssertionError, match="Either specify a filename_or_conn or pass memory=True"
|
||||
):
|
||||
db = Database("/tmp/foo.db", memory=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue