Re: [sqlite] Running sqlite script in Sqlite db using C++
On 14 May 2013, at 1:59pm, Dulini Atapattuwrote: > If anyway I omit these sqlite commands from script, so is there anyway of > providing the script file to API? If you strip out the lines which start with a dot, everything else in the script should be a legitimate SQL command. You could use the API to execute the whole thing as one bit _exec(). But it would be more conventional to read the file in a line at a time, and execute each line separately. You should write your own code to open the database file you want the results in, then do all the _exec() commands, checking the result returned to make sure there were no errors, then close the file. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Running sqlite script in Sqlite db using C++
You may want to consider writing a bash/msdos-batch file and do your stuff from your OS command line Bıt C API is quite handy, you can do most of the stuff with it. On 14/05/2013, at 10:29 PM, Dulini Atapattuwrote: > If anyway I omit these sqlite commands from script, so is there anyway of > providing the script file to API? > > > On Tue, May 14, 2013 at 6:07 PM, wrote: > >> If you are dealing with CSV files, there is a simple API I wrote you can >> use. >> >> https://github.com/fnoyanisi/sqlite3_capi_extensions >> >> I was looking for .import functionality for C API, but I ended up writing >> my own fınctions. >> >> On 14/05/2013, at 9:39 PM, Richard Hipp wrote: >> >>> On Tue, May 14, 2013 at 1:53 AM, Dulini Atapattu >>> wrote: >>> Hi all, I have some sqlite scripts with some sqlite commands like: - .headers ON - .mode CSV etc. Is there anyway of running this script in SqliteDB using Sqlite >> interface for C++, instead of redirecting the file to sqlite using sqlite command line shell? >>> >>> Those commands are implemented by the sqlite3 command-line shell, not by >>> the SQLite library. >>> >>> You can copy/paste the code out of the sqlite3 command-line shell source >>> code (www.sqlite.org/src/artifact/2109d54f67) and add that code to your >> C++ >>> application, I suppose. >>> >>> -- >>> D. Richard Hipp >>> d...@sqlite.org >>> ___ >>> sqlite-users mailing list >>> sqlite-users@sqlite.org >>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> ___ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Running sqlite script in Sqlite db using C++
If anyway I omit these sqlite commands from script, so is there anyway of providing the script file to API? On Tue, May 14, 2013 at 6:07 PM,wrote: > If you are dealing with CSV files, there is a simple API I wrote you can > use. > > https://github.com/fnoyanisi/sqlite3_capi_extensions > > I was looking for .import functionality for C API, but I ended up writing > my own fınctions. > > On 14/05/2013, at 9:39 PM, Richard Hipp wrote: > > > On Tue, May 14, 2013 at 1:53 AM, Dulini Atapattu > > wrote: > > > >> Hi all, > >> > >> I have some sqlite scripts with some sqlite commands like: > >> > >> - .headers ON > >> - .mode CSV etc. > >> > >> Is there anyway of running this script in SqliteDB using Sqlite > interface > >> for C++, instead of redirecting the file to sqlite using sqlite command > >> line shell? > > > > Those commands are implemented by the sqlite3 command-line shell, not by > > the SQLite library. > > > > You can copy/paste the code out of the sqlite3 command-line shell source > > code (www.sqlite.org/src/artifact/2109d54f67) and add that code to your > C++ > > application, I suppose. > > > > -- > > D. Richard Hipp > > d...@sqlite.org > > ___ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Running sqlite script in Sqlite db using C++
If you are dealing with CSV files, there is a simple API I wrote you can use. https://github.com/fnoyanisi/sqlite3_capi_extensions I was looking for .import functionality for C API, but I ended up writing my own fınctions. On 14/05/2013, at 9:39 PM, Richard Hippwrote: > On Tue, May 14, 2013 at 1:53 AM, Dulini Atapattu > wrote: > >> Hi all, >> >> I have some sqlite scripts with some sqlite commands like: >> >> - .headers ON >> - .mode CSV etc. >> >> Is there anyway of running this script in SqliteDB using Sqlite interface >> for C++, instead of redirecting the file to sqlite using sqlite command >> line shell? > > Those commands are implemented by the sqlite3 command-line shell, not by > the SQLite library. > > You can copy/paste the code out of the sqlite3 command-line shell source > code (www.sqlite.org/src/artifact/2109d54f67) and add that code to your C++ > application, I suppose. > > -- > D. Richard Hipp > d...@sqlite.org > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Running sqlite script in Sqlite db using C++
On Tue, May 14, 2013 at 1:53 AM, Dulini Atapattuwrote: > Hi all, > > I have some sqlite scripts with some sqlite commands like: > >- .headers ON >- .mode CSV etc. > > Is there anyway of running this script in SqliteDB using Sqlite interface > for C++, instead of redirecting the file to sqlite using sqlite command > line shell? > Those commands are implemented by the sqlite3 command-line shell, not by the SQLite library. You can copy/paste the code out of the sqlite3 command-line shell source code (www.sqlite.org/src/artifact/2109d54f67) and add that code to your C++ application, I suppose. -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Running sqlite script in Sqlite db using C++
Hi all, I have some sqlite scripts with some sqlite commands like: - .headers ON - .mode CSV etc. Is there anyway of running this script in SqliteDB using Sqlite interface for C++, instead of redirecting the file to sqlite using sqlite command line shell? Thanks ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] running a script?
It should work fine with filenames with semicolons. My problem is when I include the trailing semicolon, and it isn't really part of the filename or table name. You _might_ need to use forward slashes instead of backslashes as the path separator inside the SQLite shell on Windows. Or you might need to use double backslashes. I remember having an issue like this, but I don't remember the details. I've just started putting the files in the default dir. -Clark - Original Message From: John Salerno <[EMAIL PROTECTED]> To: sqlite-users@sqlite.org; [EMAIL PROTECTED] Sent: Wednesday, August 23, 2006 1:22:03 PM Subject: Re: [sqlite] running a script? Thanks guys. Does any of this change for Windows though? I don't believe I can use cat or | in the command prompt. I've also tried some of those structures already and there seems to be a problem with my file paths: C:\name\name\file.ext I don't know if it's the colon or the slashes, but it won't work properly. And about using .read and .import, does this mean you can't use them on files that have semicolons in them? On 8/23/06, Ulrich Schöbel <[EMAIL PROTECTED]> wrote: > On Wednesday 23 August 2006 21:45, John Salerno wrote: > > Hi everyone. Can someone tell me the proper syntax for running a sql > > script when starting up sqlite from the command line interface? > > > > Thanks, > > John > > > > --- > >-- To unsubscribe, send email to [EMAIL PROTECTED] > > --- > >-- > > cat scriptfile | sqlite3 mydb > > or > > sqlite3 -init scriptfile mydb > > or > > sqlite3 mydb < scriptfile > > or (for a single sql command) > > sqlite3 mydb 'sqlcmd' > > Kind regards > > Ulrich > > - > To unsubscribe, send email to [EMAIL PROTECTED] > - > > - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] running a script?
John Salerno said: > I'm asking about an actual file, though, not just a single query. I've > tried something like what you suggest with the file path, but it > doesn't work. > sqlite database.db < script.sql > > > On 8/23/06, Scott Baker <[EMAIL PROTECTED]> wrote: >> echo "SELECT * FROM Table" | sqlite database.bin >> >> John Salerno wrote: >> > Hi everyone. Can someone tell me the proper syntax for running a sql >> > script when starting up sqlite from the command line interface? >> > >> > Thanks, >> > John >> > >> > - >> > >> > To unsubscribe, send email to [EMAIL PROTECTED] >> > - >> > >> > >> > >> > >> >> -- >> Scott Baker - RHCE >> Canby Telcom System Administrator >> 503.266.8253 >> >> - >> To unsubscribe, send email to [EMAIL PROTECTED] >> - >> >> > > - > To unsubscribe, send email to [EMAIL PROTECTED] > - > > -- Simple Content Management http://www.ceamus.com - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] running a script?
Thanks guys. Does any of this change for Windows though? I don't believe I can use cat or | in the command prompt. I've also tried some of those structures already and there seems to be a problem with my file paths: C:\name\name\file.ext I don't know if it's the colon or the slashes, but it won't work properly. And about using .read and .import, does this mean you can't use them on files that have semicolons in them? On 8/23/06, Ulrich Schöbel <[EMAIL PROTECTED]> wrote: On Wednesday 23 August 2006 21:45, John Salerno wrote: > Hi everyone. Can someone tell me the proper syntax for running a sql > script when starting up sqlite from the command line interface? > > Thanks, > John > > --- >-- To unsubscribe, send email to [EMAIL PROTECTED] > --- >-- cat scriptfile | sqlite3 mydb or sqlite3 -init scriptfile mydb or sqlite3 mydb < scriptfile or (for a single sql command) sqlite3 mydb 'sqlcmd' Kind regards Ulrich - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] running a script?
>From the SQLite shell .read myfile Or, from the OS command shell sqlite3 foo.db ".read myfile" .help in the SQLite shell will give you the available commands Note. For me, it's a habit to end lines in the SQLite shell with a semicolon. That breaks the .read and .import commands because the SQLite shell includes the trailing semicolon as part of the file or table identifier. -Clark - Original Message From: John Salerno <[EMAIL PROTECTED]> To: sqlite-users@sqlite.org Sent: Wednesday, August 23, 2006 1:01:46 PM Subject: Re: [sqlite] running a script? I'm asking about an actual file, though, not just a single query. I've tried something like what you suggest with the file path, but it doesn't work. On 8/23/06, Scott Baker <[EMAIL PROTECTED]> wrote: > echo "SELECT * FROM Table" | sqlite database.bin > > John Salerno wrote: > > Hi everyone. Can someone tell me the proper syntax for running a sql > > script when starting up sqlite from the command line interface? > > > > Thanks, > > John > > > > - > > > > To unsubscribe, send email to [EMAIL PROTECTED] > > - > > > > > > > > > > -- > Scott Baker - RHCE > Canby Telcom System Administrator > 503.266.8253 > > - > To unsubscribe, send email to [EMAIL PROTECTED] > - > > - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] running a script?
On Wednesday 23 August 2006 21:45, John Salerno wrote: > Hi everyone. Can someone tell me the proper syntax for running a sql > script when starting up sqlite from the command line interface? > > Thanks, > John > > --- >-- To unsubscribe, send email to [EMAIL PROTECTED] > --- >-- cat scriptfile | sqlite3 mydb or sqlite3 -init scriptfile mydb or sqlite3 mydb < scriptfile or (for a single sql command) sqlite3 mydb 'sqlcmd' Kind regards Ulrich - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] running a script?
I'm asking about an actual file, though, not just a single query. I've tried something like what you suggest with the file path, but it doesn't work. On 8/23/06, Scott Baker <[EMAIL PROTECTED]> wrote: echo "SELECT * FROM Table" | sqlite database.bin John Salerno wrote: > Hi everyone. Can someone tell me the proper syntax for running a sql > script when starting up sqlite from the command line interface? > > Thanks, > John > > - > > To unsubscribe, send email to [EMAIL PROTECTED] > - > > > > -- Scott Baker - RHCE Canby Telcom System Administrator 503.266.8253 - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] running a script?
echo "SELECT * FROM Table" | sqlite database.bin John Salerno wrote: > Hi everyone. Can someone tell me the proper syntax for running a sql > script when starting up sqlite from the command line interface? > > Thanks, > John > > - > > To unsubscribe, send email to [EMAIL PROTECTED] > - > > > > -- Scott Baker - RHCE Canby Telcom System Administrator 503.266.8253 - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] running a script?
Hi everyone. Can someone tell me the proper syntax for running a sql script when starting up sqlite from the command line interface? Thanks, John - To unsubscribe, send email to [EMAIL PROTECTED] -