Hi Guys,

I'm working on a static site generator and want to use SQLite to store
metadata.   I'm using C and a small library to get the majority of the work
done.   My question is, do you have any suggestions or know where to find
more lore on how to nicely embed SQL in a program like this?

Here is an example:
char query[1024];
char *val1, *val2, *qs = "INSERT INTO posts VALUES ( NULL, '%s', '%s' );
/* initialize val1 and val2... */
snprintf(query, 1023, qs, val1, val2);
/* open database, bind statement, etc. */
sqlite3_exec(query);


The example is not nearly complete, but I'm almost certain there's a
cleaner way to seperate the SQL from the rest of the code.  Before I go
come up with my own thing, I wanted to see if there perhaps some better
solutions already out there.

Antonio R. Collins II
ramar.collins at gmail.com
http://ramarcollins.com

Reply via email to