-
-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support opening multiple databases with the same stem #509
Comments
Experimental exploratory patch: 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 |
Related problem caused by the new |
I'm fixing this in #1155. |
This was referenced Jan 25, 2021
Merged
This was referenced Feb 7, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e.g. I should be able to do this:
This currently errors because you can't have two databases taking the
/data
URL path.Instead, how about in this particular case assigning the second database
/data-1
?The text was updated successfully, but these errors were encountered: