-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bible Trivia Extreme wrote:
> (loop over spanish .txt file here while inserting)
> sprintf(query, "INSERT INTO questions VALUES('%s', '%s')", question,
> answer);

That is a *really* bad way of doing things, both from a performance point of
view and security/integrity.  (Lookup SQL injection to see why.)  If you
must use a printf style interface then at least use sqlite3_mprintf with %Q
format.  But you'll be far better off using a prepared statement and binding
strings to it in your loop.

You also don't show using a transation (BEGIN/COMMIT).  Without it each
insert will be a transaction and run at the speed of your disk.

> sqlite3_exec(db, "PRAGMA encoding = UTF8-8", 0, 0, 0);

That is a syntax error (should be UTF8).  In any event it certainly doesn't
do what you think it does.  From your code using SQLite you can't even tell
what encoding the database is in.  The SQLite API always gives you UTF8 when
using regular APIs and UTF16 when using the -16 suffix APIs.

The database encoding only affects how many bytes are used in the file for
unicode strings.  Unless you are storing a *lot* of text you generally will
not care. (And by lot I mean hundreds of megabytes and possibly gigabytes.)
 The defaults it picks are very sensible (ie match the api family you use.)

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrC6uUACgkQmOOfHg372QT9agCePAO+bc2hLFN2Oc4C0nENyxfZ
6HIAn2tyguLzHPtQ/N8oc1ro1htF5l7/
=XTkd
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to