LMHmedchem <lmh_users-gro...@molconn.com> wrote: > As it happens, some of the text strings that will be added to the database > have single quotes, > > N,N'-dimethylethylenediamine > > do I need to do anything different for these
Normally, your program shouldn't use string literals directly, but instead uses parameterized queries: http://sqlite.org/c3ref/bind_blob.html . Then you don't need to worry about single quotes. Obligatory: http://xkcd.com/327/ If for some reason you insist on embedding them directly into queries as literals, then, as Simon explained, you should double up each apostrophe, as in 'N,N''-dimethylethylenediamine'. Doesn't matter how many of them in a row, or whether they are in the beginning, end or middle of the string. E.g. if you want to insert a three-character string 'x' (including apostrophes), the correct string literal is '''x''' (three apostrophes on either side). SQLite provides a helper function sqlite3_mprintf (http://sqlite.org/c3ref/mprintf.html) , which is similar to regular sprintf() except that a) it allocates memory for the result, so you don't need to worry about sufficient buffer size, and b) it recognizes %q and %Q format specifiers, which are like %s but escape single quotes appropriately. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users