RE: [sqlite4java] fast insert

475 views
Skip to first unread message
Message has been deleted

Igor Sereda

unread,
Dec 10, 2012, 3:12:59 AM12/10/12
to sqlit...@googlegroups.com

Hi Sasha,

 

Please see http://sqlite.org/faq.html#q19

 

You need to begin a transaction with connection.exec("begin").

 

Point about documentation has been taken, but please note that sqlite4java is a wrapper, and we don’t have a goal to document SQLite database itself, which is documented pretty well on sqlite.org.

 

Kind regards,

Igor

 

 

From: sqlit...@googlegroups.com [mailto:sqlit...@googlegroups.com] On Behalf Of Sasha Kacanski
Sent: Sunday, December 09, 2012 6:25 PM
To: sqlit...@googlegroups.com
Subject: [sqlite4java] fast insert

 

Hi,
SQLITE4JAVA is very interesting wrapper for sqlite but documentation is seriously lacking.
Examples are good but not complete. Anyway I finally got some idea how to use this wrapper.
My issue is that playing with queues and single thread connection, I get really lousy insert rate.
I am trying to dump about .5 million strings in sqlite (disk)

I have all of these strings in the collection and i am looping over it and with the prep statements go about inserts.
 
        myqueue.execute(new SQLiteJob<Object>() {
            protected Object job(SQLiteConnection connection) throws SQLiteException {
                // this method is called from database thread and passed the connection
                Collection <File> allStrs = null;
                allStrs = DemoNoJDBC.getAllallStrs();
                SQLiteStatement st = connection.prepare("insert into test (id,mystrs) values( ?,?)");
               
                long ii = 0;
                for (myStr f : allStrs) {
                    ii = ii + 1;
                    st.bind(1, ii).bind(2, f.toString());
                    st.step();
                    st.reset();
                    //connection.exec(...);
                }
                connection.exec("commit");
                st.dispose();
                return null;
            }

Could some provide more complete example of the insert functionality, batch, multiple jobs in queue, asynchronously, out of order....
Pointers are fine too.
I am trying to figure out if wrapper is faster than jdbc driver, but my first impression is easy to use but not as fast.

--sasha

--
You received this message because you are subscribed to the Google Groups "sqlite4java" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlite4java/-/s5c4eBMytw4J.
To post to this group, send email to sqlit...@googlegroups.com.
To unsubscribe from this group, send email to sqlite4java...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlite4java?hl=en.

Reply all
Reply to author
Forward
0 new messages