On 31 Mar 2010, at 4:48pm, Kevin M. wrote: >> Warning: From your phrasing it's possible you're thinking of putting a >> '.read' command into your program. The '.read' command is only a command to >> the command-line tool. It's not a function of SQLite, and you can't submit >> it as a query in your program. >> >> Simon. > > Actually I was wanting to put that into a program.
I don't know how I guessed that but I'm feeling really smug now. > So, is there an API or query I can run to load an sql file all in one go (one > transaction) without having to read in the file manually and query one line > at a time? No, sorry. That's what programming languages are for. Open the file, read a line, execute it using sqlite3_exec(), read the next line, execute that, etc.. It shouldn't be much more than a five line loop. Don't forget to trap errors. Of course, sqlite3_exec() can execute multiple commands in one go. So you could open the file, read the whole thing into one huge string, close the file, then execute the string. That will work perfectly if your have enough memory and disk space. But if you aren't confident about the size of the text file before you start, it's probably better to do it line by line. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users