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/509#issuecomment-502393573,https://api.github.com/repos/simonw/datasette/issues/509,502393573,MDEyOklzc3VlQ29tbWVudDUwMjM5MzU3Mw==,9599,2019-06-15T19:32:56Z,2019-06-15T19:32:56Z,OWNER,"Experimental exploratory patch: ```diff diff --git a/datasette/app.py b/datasette/app.py index 2ef7da4..ca51866 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -164,8 +164,10 @@ class Datasette: is_memory = True is_mutable = path not in self.immutables db = Database(self, path, is_mutable=is_mutable, is_memory=is_memory) + i = 1 if db.name in self.databases: - raise Exception(""Multiple files with same stem: {}"".format(db.name)) + db.stem = db.name + ""-"" + str(i) + i += 1 self.databases[db.name] = db self.cache_headers = cache_headers self.cors = cors diff --git a/datasette/database.py b/datasette/database.py index e491577..75c8681 100644 --- a/datasette/database.py +++ b/datasette/database.py @@ -14,6 +14,8 @@ from .inspect import inspect_hash class Database: + stem = None + def __init__(self, ds, path=None, is_mutable=False, is_memory=False): self.ds = ds self.path = path @@ -73,6 +75,8 @@ class Database: def name(self): if self.is_memory: return "":memory:"" + elif self.stem: + return self.stem else: return Path(self.path).stem ``` ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",456568880, https://github.com/simonw/datasette/issues/509#issuecomment-748356637,https://api.github.com/repos/simonw/datasette/issues/509,748356637,MDEyOklzc3VlQ29tbWVudDc0ODM1NjYzNw==,9599,2020-12-18T22:50:03Z,2020-12-18T22:50:03Z,OWNER,Related problem caused by the new `_schemas` database - if a user attempts to open their own `_schemas.db` file it will fail. I'd like to open and mount that as `/_schemas_` instead.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",456568880, https://github.com/simonw/datasette/issues/509#issuecomment-749738241,https://api.github.com/repos/simonw/datasette/issues/509,749738241,MDEyOklzc3VlQ29tbWVudDc0OTczODI0MQ==,9599,2020-12-22T19:38:14Z,2020-12-22T19:38:14Z,OWNER,I'm fixing this in #1155.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",456568880, https://github.com/simonw/datasette/issues/509#issuecomment-749749948,https://api.github.com/repos/simonw/datasette/issues/509,749749948,MDEyOklzc3VlQ29tbWVudDc0OTc0OTk0OA==,9599,2020-12-22T20:03:10Z,2020-12-22T20:03:10Z,OWNER,"If you open multiple files with the same filename, e.g. like this: datasette fixtures.db templates/fixtures.db plugins/fixtures.db You'll now get this: ","{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 1, ""rocket"": 0, ""eyes"": 0}",456568880,