1

I'm writing a .bat file that calls sqlite3 shell (opens existing database file) and passes an .sql file with commands into it. It looks like following in .bat file:

sqlite3 %1 < "%~0\..\xtra.sql"

, where %1 is path to database file.

The problem is - in .sql script I need to use filename of database; but I can't find any information which command use to get it. Alternatively,if there is a way to pass parameters into sqlite3 shell (like into windows cmd), I could use it too.

1 Answer 1

2

The pragma database_list; command will return the list of currently attached databases. This information can be retrieved as a table-valued function (from version 3.16.0, documented here).

As you need your default database file, then if you are using an updated sqlite shell version, you can use

select file from pragma_database_list where name='main';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.