-
-
Notifications
You must be signed in to change notification settings - Fork 813
Closed
Labels
Milestone
Description
I was trying to initalize SpatiaLite in a write connection:
>>> from datasette.app import Datasette
>>> ds = Datasette(memory=True, files=[], sqlite_extensions=["spatialite"])
>>> db = ds.add_memory_database('geo')
>>> await db.execute_write("select InitSpatialMetadata(1)")
UUID('3f143baa-4e3d-5842-a36f-4fa2f683b72f')
no such function: InitSpatialMetadataIt looks like the code that loads additional modules only works on read-only connections, not on write connections:
datasette/datasette/database.py
Lines 146 to 153 in 92a5280
| async def execute_fn(self, fn): | |
| def in_thread(): | |
| conn = getattr(connections, self.name, None) | |
| if not conn: | |
| conn = self.connect() | |
| self.ds._prepare_connection(conn, self.name) | |
| setattr(connections, self.name, conn) | |
| return fn(conn) |
Compared to:
datasette/datasette/database.py
Lines 124 to 132 in 92a5280
| def _execute_writes(self): | |
| # Infinite looping thread that protects the single write connection | |
| # to this database | |
| conn_exception = None | |
| conn = None | |
| try: | |
| conn = self.connect(write=True) | |
| except Exception as e: | |
| conn_exception = e |
Reactions are currently unavailable