[Question | Feature Request] Open database and execute bootsprap commands via CLI
-
Which driver are you using and version of it: SQLite
-
Which TablePlus build number are you using: 600
Question / Feature request:
When creating a database connection and saving it in the connection list, we have the option to define bootstrap commands. For most of our projects using SQLite, we always enable foreign key support with PRAGMA foreign_keys = ON;.
However, we usually have a shortcut in each project that opens the database in TablePlus via a CLI command like:
open -a TablePlus \"file://$(pwd)/storage/db.sqlite\"
This is more convenient for everyone using the project.
Is it possible to open a database connection via the command line while specifying these bootstrap commands? Or is there another way to enable foreign key support when opening an SQLite database via the command line?
Other related issues:
- https://github.com/TablePlus/TablePlus/issues/393
- https://github.com/TablePlus/TablePlus/issues/227
- https://github.com/TablePlus/TablePlus/issues/3109
I know it is a bit hack, but you can do something like this
open -a TablePlus "sqlite://@%2FUsers%2Fr%2FDownloads%2Ftest.sqlite3/test.sqlite3?table=YOU_TABLE_NAME&raw=YOUR_COLUMN_ID=VALUE;PRAGMA foreign_keys = ON;"
It will open connection, open the table, filter with column=value and then also execute the PRAGMA foreign_keys = ON;
Unfortunately, I tried several variations but couldn't get it to work.
Did the command PRAGMA foreign_keys = ON execute successfully on your end? Were foreign key constraints enforced afterward?
Seems like PRAGMA are not working in queries, only pragma functions but there is no such function for the foreign_keys PRAGMA. :/