[sqlite] Importing file from C-code

2009-07-07 Thread Alberto Daniotti
Good Morning.
I have a question. I want integrate sqlite in a c-program. I want to know if is 
possible import a table from a external text file without using INSERT (it's 
too slow) and if it's how i must do.
Thanks 
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Importing file from C-code

2009-07-07 Thread Markus Hoenicka
Quoting Alberto Daniotti albertodanio...@libero.it:

 Good Morning.
 I have a question. I want integrate sqlite in a c-program. I want to  
 know if is possible import a table from a external text file without  
 using INSERT (it's too slow) and if it's how i must do.

How often would you need to do that? If it's a one-time initialization  
of your database, I can't imagine why using INSERT is too slow. If it  
really is, all you can do is to ship an existing database with the  
table already loaded (a SQLite database is just one file). If that is  
not possible, you may have to rewrite your code to avoid implicit  
transactions around each INSERT statement, see  
http://www.sqlite.org/faq.html#q19

regards,
Markus


-- 
Markus Hoenicka
markus.hoeni...@cats.de
(Spam-protected email: replace the quadrupeds with mhoenicka)
http://www.mhoenicka.de


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Importing file from C-code

2009-07-07 Thread Simon Slavin

On 7 Jul 2009, at 10:39am, Alberto Daniotti wrote:

 I have a question. I want integrate sqlite in a c-program. I want to  
 know if is possible import a table from a external text file without  
 using INSERT (it's too slow) and if it's how i must do.

If INSERT is too slow for you, you probably are not using transactions  
correctly.  Use a 'BEGIN TRANSACTION' before the first INSERT and a  
'COMMIT TRANSACTION' after the last one.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Importing file from C-code

2009-07-07 Thread Alberto Daniotti
Thank you for the answer.
Could you give me an example of use of BEGIN TRANSACTION?
Thanks

- Original Message - 
From: Simon Slavin slav...@hearsay.demon.co.uk
To: General Discussion of SQLite Database sqlite-users@sqlite.org
Sent: Tuesday, July 07, 2009 1:22 PM
Subject: Re: [sqlite] Importing file from C-code



 On 7 Jul 2009, at 10:39am, Alberto Daniotti wrote:

 I have a question. I want integrate sqlite in a c-program. I want to
 know if is possible import a table from a external text file without
 using INSERT (it's too slow) and if it's how i must do.

 If INSERT is too slow for you, you probably are not using transactions
 correctly.  Use a 'BEGIN TRANSACTION' before the first INSERT and a
 'COMMIT TRANSACTION' after the last one.

 Simon.
 ___
 sqlite-users mailing list
 sqlite-users@sqlite.org
 http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users






Nessun virus nel messaggio in arrivo.
Controllato da AVG - www.avg.com
Versione: 8.5.375 / Database dei virus: 270.13.6/2221 -  Data di rilascio: 
07/06/09 17:54:00

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Importing file from C-code

2009-07-07 Thread Simon Slavin

On 7 Jul 2009, at 3:06pm, Alberto Daniotti wrote:

 Thank you for the answer.
 Could you give me an example of use of BEGIN TRANSACTION?

BEGIN TRANSACTION;
INSERT INTO favouriteColour (person,colour) VALUES ('Jenny', 'orange');
INSERT INTO favouriteColour (person) VALUES ('John');
INSERT INTO favouriteColour (person,colour) VALUES ('Fred', 'blue');
INSERT INTO bestTrinket (colour,trinketName) VALUES ('white', 'hat');
INSERT INTO bestTrinket (colour,trinketName) VALUES ('blue',  
'umbrella');
COMMIT TRANSACTION;

See http://www.sqlite.org/lang_transaction.html for the reason why.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users