Dear Christian,

Thanks again for your help.
Before I got your message, I did try working with shell.c but was not able
to get the code to work(I forget what errors I was getting but I believe the
compiler did not like sqlite3_bind_text)


BUT...

I was able to create a large table on the fly (i int, d double).
I inserted 1,000,000 records on a p4 and it took just 65 seconds!

The salient code is:

//**********************************
string prepare = "insert into small values(-1,-1);";
ans = sqlite3_prepare(lite3,prepare.c_str(),prepare.length(), &ppStmt,
&pzTail);
 
ans = sqlite3_step(ppStmt);

string insert = "insert into small values(";
 for (int i = 0; i < 1000000-1; i++)
  {
   I = i;
   D = i*.01;
   char iC[10],
        dC[10];

   sprintf(iC, "%d",  I);
   sprintf(dC, "%lf", D);

   string vals = insert
               + string(iC) + ","
               + string(dC) + ");";

   ans = sqlite3_exec(lite3, vals.c_str(),  tryCB, &pArg, &errMsg);
  }
//**********************************

My only question is why does it work??

I understand that sqlite3_prepare prepares the sql statemen "prepare", but
why isn't vals.c_str() considered to be a new sql statement?


Thanks again,
-Marc






Reply via email to