2

Having a scripted build process on Windows 10 (CMD or Powershell, both is possible) I want to build a spatialite database with the ready to use but empty schema created from a couple of sql files.

I already found out, that it is possible to call

spatialite.exe -init <SqlFile>.sql <OutputSpatialiteDatabase>.sqlite

which creates an empty sqlite database with the given name, executes all commands in the sql script on it and then provides the interactive command shell on it (it does NOT exit).

Thats already pretty close to what I want, but I want to execute multiple Sql Files as these represent multiple (optional) parts of the schema that I want to create just on purpose (like use case specific modules).

Also the script should exit correctly afterwards and dont be stuck in a spatialite interactive shell.

2

Lazy me to blame, I've just found the solution by myself after consulting SQLite docs.

As with the SQLite exe it`s the same with spatialite exe and the script can just be piped in by

spatialite YourSpatialiteDb.sqlite < SqlFile.sql

The spatialite also exits gently afterwards, so this works like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.