sqlitebrowser / sqlitebrowser

Official home of the DB Browser for SQLite (DB4S) project. Previously known as "SQLite Database Browser" and "Database Browser for SQLite". Website at:
https://sqlitebrowser.org
Other
21.16k stars 2.13k forks source link

Ablity to save and run predefined SQL scripts with shortcut keys #2903

Open Bahaa-Sobhy opened 2 years ago

Bahaa-Sobhy commented 2 years ago

Describe the new feature

We need an ability to store SQL scripts, and call them by one click or shortcut keys; An example of a problem: When we select all records of a table, and we delete them all, we need to reset the increment number of the primary/unique key to start over from 1, but the scenario now is that we still get the new record with the old increment number example 519. So if there's an ability to run a predefined script by a shortcut keys or one click that set the auto increment to 1 would be fine.

Now let's assume this, for example, from the tools menu>Define new script> we get a window with SQL script and Shortcut Keys assignment inputs>Save; once we want to run this script, we do the shortcut keys, and we get the script executed; in the mentioned example, the whole table records will be removed and the increment column will start over from 1 as we want;

Additional info

Please answer these questions before submitting your feature request.

Is your feature request related to an issue? Please include the issue number.

No

Does this feature exist in another product or project? Please provide a link.

No

Do you have a screenshot? Please add screenshots to help explain your idea.

No, screenshot doesn't do anything

chrisjlocke commented 2 years ago

Not so much pre-defined scripts with shortcut keys, but you can store SQL scripts in tabs which can be saved with the database (in a project file). This means that instead of opening the database, you open the project file, which opens the database and a predefined number of sql tabs with scripts already in them. You still have to click in them and press [F5] to execute the scripts...

As an aside, a 'management tool' that connects to a database and runs sql scripts would be easy to knock up in a plethora of languages. My fave is vb.net as I program in that every day, so if you needed a 'quick 'n dirty' tool to do that, that would work. Unfortunately, vb.net tends to be for Windows only (although there is .Net core now...) so that may not be as useful for you .... unsure what your OS is you're using.

Bahaa-Sobhy commented 2 years ago

hi @chrisjlocke Thanks for your quick reply; I agree with you that saving a project is a way of help, but I would recommend the scripts scenarios rather than saving a project with a specific database file, because, what If I have a new db file and want to quickly drop it, the case here needs the predefined scripts with a shortcut key, for example to tun this simple script: DELETE FROM sqlite_sequence; so the increment will start over from 1;

As for the management tool, I use Windows 10, and I know that vb.net is a programming language, isn't it? if so then how to use it for SQLite tasks?

chrisjlocke commented 2 years ago

Having predefined scripts would certainly be handy. I program in VB a lot, so when creating a database application, I require a database to have a set of standard tables - log table, users table, etc, etc. I can see the use for it. A similar request in the past was some sort of history of SQL commands. at the moment, you can save SQL tabs, but a generic history of entered SQL would be useful, and this could link in with that.

As for VB, that's quite a learning curve, but depending on your skillset, achievable. I can knock up a small tool to do this, as this enhancement wouldn't be included in DB4S for a while - there are a couple of hundred open issues and development has stalled a bit recently.

Bahaa-Sobhy commented 2 years ago

I see @chrisjlocke well I'm C# developer, and there are way to create my own SQLite tool, but you know, it's an issue of time.

Thanks for your responses :) have a good day!

chrisjlocke commented 2 years ago

You simply need the system.data.sqlite DLL. https://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki

A fantastic library - just two DLLs (well, three to accommodate 32 and 64-bit) and very easy to use - read data into a data table, or simply execute SQL statements. Happy to build the above tool and walk it through with you. I'll teach you the library and you can teach me c# ;)

Bahaa-Sobhy commented 2 years ago

yeah, @chrisjlocke I remember that I used this library maybe 2 or 3 years ago in some old project... but still I agree with you about the deal :) ...

little-brother commented 2 years ago

Does this feature exist in another product or project? Please provide a link. No

What about a SSMS Shortcut queries?

chrisjlocke commented 2 years ago

Handy ... didn't know about that, and use SSMS every day 😁😁