-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
If you open a CSV and then install a plugin the CSV table vanishes #42
Comments
This should definitely be fixed. The problem is, how to do it? The "Open CSV" option loads the CSV into memory. That memory then gets wiped when the server restarts after the plugin is installed. Three options I can think of:
|
Option 2 looks like it might be a good one, thanks to the Here's a proof of concept:
Having run that I have a file in
|
I found that fix for |
But... how would I restore that saved temporary database file back INTO the in-memory database? Could I use |
https://www.sqlite.org/lang_vacuum.html says:
Datasette in https://github.com/simonw/datasette/blob/d57ab156b35ec642549fb69d08279850065027d2/datasette/database.py#L72-L79 does this: if self.memory_name:
uri = "file:{}?mode=memory&cache=shared".format(self.memory_name)
conn = sqlite3.connect(
uri,
uri=True,
check_same_thread=False,
) So it should be possible to use |
Yes, this works: >>> import sqlite3
>>> backup_db = sqlite3.connect("/tmp/backup.db", uri=True)
>>> conn = sqlite3.connect("file:temporary?mode=memory&cache=shared", uri=True)
>>> backup_db.execute("vacuum into 'file:temporary?mode=memory&cache=shared'")
<sqlite3.Cursor object at 0x11099af80>
>>> conn.execute("select * from foo").fetchall()
[(1,), (2,), (3,)] The order mattered - I had to open The |
This is going to need some new API endpoints in
I'll leave it to the Electron app to define the file - I thought about using |
This is because opening a CSV imports into the
temporary
in-memory database, and installing a plugin restarts the server.Could maybe keep track of which CSVs have been opened and re-import them after a restart of the server within the current application session?
Might not be worth fixing this.
The text was updated successfully, but these errors were encountered: