[sqlite] how to COPY FROM stdin in 3.x?

Wed, 04 May 2005 13:27:13 -0700

According to http://www.sqlite.org/lang_copy.html, COPY FROM has been removed in 3.0 because of UTF8/16 difficulties. The command-line workaround won't help in my situation because I need to bulk insert from a C++ program.

I couldn't find any reference to COPY FROM SQL workarounds in the archives.

Here's what I'm really trying to do: I'm evaluating SQLite's insertion performance to see if it can handle to insertion rate we need to match the arrival rate of the data we're logging.

I'm receiving network packets with 22 flow records each, and need to insert each record into a table.

My postgresql code just does a COPY flows FROM stdin, followed by 22 lines of values:

PQexec(gConn1, "COPY flows FROM stdin");
...22 times...
PQputline(gConn1, line);
PQputline(gConn1, "\\.\n"); //required by "FROM stdin" to terminate the sequence
PQendcopy(gConn1);
PQexec(gConn1, "COMMIT");


I can rewrite this to do individual inserts, but would like to find out whether there's a better workaround/idiom for this.

Thanks,
scott

Reply via email to