Options for access to db files

As we know it is best to hide database files in a folder named .data to insure they aren’t copied along with the project. That folder isn’t imported from GitHub either which tends to mean that we can’t store a populated db file and expect to host it on Glitch. So I’m asking what do people tend to do? Obviously scripts can be written to populate the db and that isn’t totally unreasonable but it isn’t always practical.

Is there a way to upload a file directly to a known folder (.data in this case) to Glitch? I can clearly rename it to data but that means it is no longer hidden). What do devs tend to do in this case?


1 Like

I thought of a solution that could work but doesn’t seem to have worked. I need to know if the glitch “folders” correspond to folders such that Node’s fs.rename() function would operate. I tried to add a marker file that if present when the app starts it moves a couple of files from the root to the data folder. The section of code ran but the files did not move.

Ultimately these would have to move into the .data folder so opinions on whether that could work would be welcome.

The only way I can envision populating a db file at the moment is via posting through the app which isn’t ideal if (for instance) I needed to rewind a db to an earlier backup.

They are, but we don’t have a way to upload databases to the root folder either, so I don’t think this has been a popular option either.

This sounds like it could be a case of the editor getting out of sync with the filesystem. Check if running refresh in the terminal brings the editor up to date with the changes made outside the editor.

Experience report: building an administrative connection to Glitch I’ve posted some info on the various techniques available for us to transfer data to a project. I wrote up an tool based on the findings. You can get that here Releases · wh0/snail-cli · GitHub if you want to try it out. Take a look at snail pipe --help and snail rsync --help in particular.

It turns out we can copy directly into the root folder if we simply change the file extension to something neutral, like .txt. The “move” operation can change the extension. I will try my tests again.

I will check the links you posted, thanks. Otherwise I’m pursuing a semi-automated way to generate schema and table insert scripts from a local copy such that I could execute that in a .js file intended to generate the db from scratch. If you know if a utility or website that demonstrates that I’d love a pointer. Thanks.

I’ve heard about this, but it’s not suitable for all databases. You should know though that Glitch performs this kind of “upload” as a transfer of Unicode text, not as binary data. I suggest you check that your file doesn’t get corrupted.

I think you’re describing a database migration. And that really depends on what database you’re using and what library you’re using to connect to it. But maybe the term will help you find materials for the tools you’re using :woman_shrugging:

Not so good if the contents of the file don’t remain the same :slight_smile: I do believe that I have a solution for my particular issue. I didn’t realize there was a dump command in Sqlite3 that will produce an ASCII-based transaction file that will recreate the tables and upload the data as a transaction.

While I can’t directly pipe the file back in (I don’t think) I can certainly read the file on a line-by-line basis and process it. I’m going to give it a try.

As for your “project” I read most of it. I think I would favor an “admin” switch in Glitch that provided whatever access was necessary. If it is a safety issue it should only be for Glitch’s safety not the safety of our project files. That’s what backups are for :slight_smile:

And I tested it again and you were correct the editor was out of sync. The terminal showed me that the file had indeed moved.

Oops I guess I was operating on an assumption that we had zero access to the /app/.data folder. From the terminal it appears that we do. With the possible issue of binary uploads it seems that this simple upload a copy should do the job.