home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 747774855

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/1151#issuecomment-747774855 https://api.github.com/repos/simonw/datasette/issues/1151 747774855 MDEyOklzc3VlQ29tbWVudDc0Nzc3NDg1NQ== 9599 2020-12-17T23:42:34Z 2020-12-17T23:42:34Z OWNER

This worked as a prototype: ```diff diff --git a/datasette/database.py b/datasette/database.py index 412e0c5..a90e617 100644 --- a/datasette/database.py +++ b/datasette/database.py @@ -24,11 +24,12 @@ connections = threading.local()

class Database: - def init(self, ds, path=None, is_mutable=False, is_memory=False): + def init(self, ds, path=None, is_mutable=False, is_memory=False, uri=None): self.ds = ds self.path = path self.is_mutable = is_mutable self.is_memory = is_memory + self.uri = uri self.hash = None self.cached_size = None self.cached_table_counts = None @@ -46,6 +47,8 @@ class Database: }

 def connect(self, write=False):
  • if self.uri:
  • return sqlite3.connect(self.uri, uri=True, check_same_thread=False) if self.is_memory: return sqlite3.connect(":memory:") # mode=ro or immutable=1? Then in `ipython`: from datasette.app import Datasette from datasette.database import Database ds = Datasette([]) db = Database(ds, uri="file:datasette?mode=memory&cache=shared", is_memory=True) await db.execute_write("create table foo (bar text)") await db.table_names()

Outputs ["foo"]

db2 = Database(ds, uri="file:datasette?mode=memory&cache=shared", is_memory=True) await db2.table_names()

Also outputs ["foo"]

```

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
770448622  
Powered by Datasette · Queries took 5.004ms · About: github-to-sqlite