vendredi 25 mars 2016

Elegant way to run (SQLite) database initialization script in C/C++

I'm creating a simple application in C/C++ that logs events on an SQLite3 database. After opening the database handle, I have to run a long initialization SQL script with many CREATE TABLE, ATTACH, PRAGMA, CREATE INDEX and some default INSERT statements.

How do I do this while keeping the C/C++ code clean?

More details:

  • I'd like to keep the SQL initialization script as a separate file i.e. avoid any hardcoding of SQL queries. Reasons: code highlighting, Git, separating differente languages.
  • The script contains multi-line queries, so reading and executing line-by-line is impractical, since it should be (I think) query-by-query.

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire