mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Documentation and tests for db.is_mutable
This commit is contained in:
parent
b86f94883b
commit
af12f45c2b
2 changed files with 12 additions and 0 deletions
|
|
@ -480,6 +480,12 @@ The ``Database`` class also provides properties and methods for introspecting th
|
||||||
``db.mtime_ns`` - integer or None
|
``db.mtime_ns`` - integer or None
|
||||||
The last modification time of the database file in nanoseconds since the epoch. ``None`` for ``:memory:`` databases.
|
The last modification time of the database file in nanoseconds since the epoch. ``None`` for ``:memory:`` databases.
|
||||||
|
|
||||||
|
``db.is_mutable`` - boolean
|
||||||
|
Is this database mutable, and allowed to accept writes?
|
||||||
|
|
||||||
|
``db.is_memory`` - boolean
|
||||||
|
Is this database an in-memory database?
|
||||||
|
|
||||||
``await db.table_exists(table)`` - boolean
|
``await db.table_exists(table)`` - boolean
|
||||||
Check if a table called ``table`` exists.
|
Check if a table called ``table`` exists.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,4 +213,10 @@ async def test_mtime_ns(db):
|
||||||
|
|
||||||
def test_mtime_ns_is_none_for_memory(app_client):
|
def test_mtime_ns_is_none_for_memory(app_client):
|
||||||
memory_db = Database(app_client.ds, is_memory=True)
|
memory_db = Database(app_client.ds, is_memory=True)
|
||||||
|
assert memory_db.is_memory is True
|
||||||
assert None is memory_db.mtime_ns
|
assert None is memory_db.mtime_ns
|
||||||
|
|
||||||
|
|
||||||
|
def test_is_mutable(app_client):
|
||||||
|
assert Database(app_client.ds, is_memory=True, is_mutable=True).is_mutable is True
|
||||||
|
assert Database(app_client.ds, is_memory=True, is_mutable=False).is_mutable is False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue