litecli icon indicating copy to clipboard operation
litecli copied to clipboard

feature request: execute a set of commands during startup

Open aborruso opened this issue 6 years ago • 9 comments

Hi, it would be great to the option to execute a set of commands during startup.

In example I often load pcre module and I would like to have it as default behavior.

Thank you

aborruso avatar Feb 11 '19 12:02 aborruso

I think you can store your commands in a file and then pass them as command line argument to litecli.

elig0n avatar May 21 '19 06:05 elig0n

Hi @elig0n and how to run at start in example .load /usr/lib/sqlite3/pcre.so?

It would be nice if litecli read .sqliterc standard file.

Thank you

aborruso avatar May 21 '19 07:05 aborruso

@aborruso that's a good idea. For now, I think you can use the favorite query to store a set of commands, and run it with a short name.

zzl0 avatar Oct 28 '19 03:10 zzl0

I was about to file an identical issue before I found this one. This would be a useful feature for me as well. Adding my +1!

rmcgibbo avatar Feb 23 '22 18:02 rmcgibbo

Just found this issue, this is the first thing I was looking for in the configuration. :+1:

I have a nice .sqliterc with features i'd like to keep using:

.mode column
.headers on
.nullvalue <null>

-- always explain query plan
.eqp on
pragma foreign_keys = ON;

.print "Databases:"
.databases
.print "\nTables:"
.tables
.print "\n"

.changes on
.timer on

fdietze avatar Jun 04 '22 17:06 fdietze

@fdietze The default behavior of litecli seems to match most of the things in your sqliterc file.

The default table format already has headers on. The null value is already represented as <null>. The number of affected row are always printed (.changes on) The timing information is also on by default (.timer on)

The goal with litecli is to ship with sane defaults so people aren't spending a lot of time trying to mess with configuration files to get reasonable behavior.

That said I can see that people might still want this feature. I'm happy to help someone get started if they're interested in contributing this feature.

amjith avatar Jun 04 '22 18:06 amjith

The goal with litecli is to ship with sane defaults so people aren't spending a lot of time trying to mess with configuration files to get reasonable behavior.

That's what I like about it! Thank you for your work!

fdietze avatar Jun 07 '22 17:06 fdietze

Came here to open this issue. It would be great to auto set foreign keys as well as display the tables of the db.

bjornasm avatar May 03 '23 07:05 bjornasm

I have started implemented this now. If people don't mind that it might be a bit below the standard of the rest of the codebase I will submit a pull request (I will ofc do my best). If nothing else it can serve as a starting point. Thinking that it can take in startup commands specified in the config file. Will first focus on implementing the core functionality, then add some basic error handling (which I am sure can be expanded). Already have a minimal running example. @fdietze @amjith @aborruso

bjornasm avatar May 03 '23 09:05 bjornasm