Re: [sqlite] select from commandprompt with output to file

2006-11-17 Thread John Stanton

RB Smissaert wrote:

Have tried this now and working beautifully.
One thing I couldn't figure out is how to set the row delimiter.
I can set the column delimiter fine with .mode csv, but couldn't see
something similar for the rows. The delimiter for rows should be vbCrLf.

As SQLite is written in C does it have the option to output to memory, say
an array and produce the pointer to that memory, rather than a text file?

RBS

-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: 17 November 2006 15:04

To: sqlite-users@sqlite.org
Subject: Re: [sqlite] select from commandprompt with output to file

RB Smissaert wrote:


How would I run these 4 commands via a .bat file or via whatever means:

cd c:\test\ReadCodes
c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db"
.output testfile.txt
select * from readcode where read_code glob 'G2*';

It must be simple, but I can't see it.

 


RBS,

You need to put all your sqlite shell commands in one file, say 
sqlitecmds.txt. This includes the dot commands and the SQL statements. 
So sqlitecmds.txt contains:


.output testfile.txt
select * from readcode where read_code glob 'G2*';

Then you need to put your DOS shell commands in another file, say 
readcode.bat. This file will contain the commnad to run sqlite and 
redirect its input to the file of sqlite commnads above. So readcode.bat 
contains:


cd c:\test\ReadCodes
c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db < sqlitecmds.txt

Then you tell the DOS shell (actually cmd.exe) to run the commands in 
your readcode.bat file by typing the batch file name at the command prompt.


C:\>readcode

This will execute your batch file commands, which will run the sqlite 
shell program, which will read and execute the commands in the sqlite 
commands file, which will write its output to the file testfile.txt in 
the current directory (which will be C:\test\ReadCodes).


HTH
Dennis Cote




-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-

You can achieve the structure you want by memory mapping a file and 
writing to it.  Then it will be in virtual memory and you will have a 
pointer to it.  It is not an Sqlite feature, but one your programming 
language can do through its API.  On Windows just use the regular Win32 
API to map the file and to write.  You can then access everything you 
wrote using the pointer.


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] select from commandprompt with output to file

2006-11-17 Thread RB Smissaert
Have tried this now and working beautifully.
One thing I couldn't figure out is how to set the row delimiter.
I can set the column delimiter fine with .mode csv, but couldn't see
something similar for the rows. The delimiter for rows should be vbCrLf.

As SQLite is written in C does it have the option to output to memory, say
an array and produce the pointer to that memory, rather than a text file?

RBS

-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: 17 November 2006 15:04
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] select from commandprompt with output to file

RB Smissaert wrote:
> How would I run these 4 commands via a .bat file or via whatever means:
>
> cd c:\test\ReadCodes
> c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db"
> .output testfile.txt
> select * from readcode where read_code glob 'G2*';
>
> It must be simple, but I can't see it.
>
>   
RBS,

You need to put all your sqlite shell commands in one file, say 
sqlitecmds.txt. This includes the dot commands and the SQL statements. 
So sqlitecmds.txt contains:

.output testfile.txt
select * from readcode where read_code glob 'G2*';

Then you need to put your DOS shell commands in another file, say 
readcode.bat. This file will contain the commnad to run sqlite and 
redirect its input to the file of sqlite commnads above. So readcode.bat 
contains:

cd c:\test\ReadCodes
c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db < sqlitecmds.txt

Then you tell the DOS shell (actually cmd.exe) to run the commands in 
your readcode.bat file by typing the batch file name at the command prompt.

C:\>readcode

This will execute your batch file commands, which will run the sqlite 
shell program, which will read and execute the commands in the sqlite 
commands file, which will write its output to the file testfile.txt in 
the current directory (which will be C:\test\ReadCodes).

HTH
Dennis Cote




-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] select from commandprompt with output to file

2006-11-17 Thread RB Smissaert
Dennis,

Thanks for that. Will try it later and let you know.
Definitely one I couldn't have figured out myself.

RBS

-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: 17 November 2006 15:04
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] select from commandprompt with output to file

RB Smissaert wrote:
> How would I run these 4 commands via a .bat file or via whatever means:
>
> cd c:\test\ReadCodes
> c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db"
> .output testfile.txt
> select * from readcode where read_code glob 'G2*';
>
> It must be simple, but I can't see it.
>
>   
RBS,

You need to put all your sqlite shell commands in one file, say 
sqlitecmds.txt. This includes the dot commands and the SQL statements. 
So sqlitecmds.txt contains:

.output testfile.txt
select * from readcode where read_code glob 'G2*';

Then you need to put your DOS shell commands in another file, say 
readcode.bat. This file will contain the commnad to run sqlite and 
redirect its input to the file of sqlite commnads above. So readcode.bat 
contains:

cd c:\test\ReadCodes
c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db < sqlitecmds.txt

Then you tell the DOS shell (actually cmd.exe) to run the commands in 
your readcode.bat file by typing the batch file name at the command prompt.

C:\>readcode

This will execute your batch file commands, which will run the sqlite 
shell program, which will read and execute the commands in the sqlite 
commands file, which will write its output to the file testfile.txt in 
the current directory (which will be C:\test\ReadCodes).

HTH
Dennis Cote




-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] select from commandprompt with output to file

2006-11-17 Thread Dennis Cote

RB Smissaert wrote:

How would I run these 4 commands via a .bat file or via whatever means:

cd c:\test\ReadCodes
c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db"
.output testfile.txt
select * from readcode where read_code glob 'G2*';

It must be simple, but I can't see it.

  

RBS,

You need to put all your sqlite shell commands in one file, say 
sqlitecmds.txt. This includes the dot commands and the SQL statements. 
So sqlitecmds.txt contains:


   .output testfile.txt
   select * from readcode where read_code glob 'G2*';

Then you need to put your DOS shell commands in another file, say 
readcode.bat. This file will contain the commnad to run sqlite and 
redirect its input to the file of sqlite commnads above. So readcode.bat 
contains:


   cd c:\test\ReadCodes
   c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db < sqlitecmds.txt

Then you tell the DOS shell (actually cmd.exe) to run the commands in 
your readcode.bat file by typing the batch file name at the command prompt.


   C:\>readcode

This will execute your batch file commands, which will run the sqlite 
shell program, which will read and execute the commands in the sqlite 
commands file, which will write its output to the file testfile.txt in 
the current directory (which will be C:\test\ReadCodes).


HTH
Dennis Cote



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] select from commandprompt with output to file

2006-11-17 Thread RB Smissaert
Latest SQLite, 2000 to XP.
I have the output to text working now when I type it at the command prompt,
but I now need to figure out how to do the whole sequence without any user
action. I has to run from VB or maybe a VBS file or anything that can be
initiated from VB/VBA.

RBS

-Original Message-
From: Dan Kennedy [mailto:[EMAIL PROTECTED] 
Sent: 17 November 2006 08:09
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] select from commandprompt with output to file


What sqlite versions, OS etc.? This worked for me:

$ sqlite3
SQLite version 3.2.8
Enter ".help" for instructions
sqlite> create table abc(a, b, c);
sqlite> .output out.txt
sqlite> select * from sqlite_master;
sqlite> .quit 
$ cat out.txt
table|abc|abc|2|CREATE TABLE abc(a, b, c)


> 
> How do I do this:
> From the command prompt issue a simple select query to a specified
database
> and direct the output to a file.
> I can see there is the .output FILENAME option, but nothing seems to
happen.
> .output stdout works fine with output to the screen.
> Must be overlooking something simple here.
> 
> RBS
> 
> 
> 
>

-
> To unsubscribe, send email to [EMAIL PROTECTED]
>

-
> 
> 



 


Sponsored Link

$200,000 mortgage for $660/ mo - 
30/15 yr fixed, reduce debt - 
http://yahoo.ratemarketplace.com


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] select from commandprompt with output to file

2006-11-17 Thread RB Smissaert
Yes, from a DOS command shell, but when I get it working I would like to
avoid the DOD box.
I have been trying your suggestion in various forms, but sofar no success
yet. Something is happening though, so it looks like it might work.
I get various error messages: path can't be found, incomplete SQL, cannot
find unnamed pipe etc. Tried lots of things, but I know even less about DOS
then you and I am just messing about in the dark. I will get it and thanks
for the starting point.

RBS


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: 17 November 2006 01:15
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] select from commandprompt with output to file

"RB Smissaert" <[EMAIL PROTECTED]> writes:

> How would I run these 4 commands via a .bat file or via whatever means:
>
> cd c:\test\ReadCodes
> c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db"
> .output testfile.txt
> select * from readcode where read_code glob 'G2*';

I haven't been tracking this thread so apologies if I'm misunderstanding
what
you want.  Are you doing this from a DOS (Command) shell?  I'm far from a
DOS
expert, but how about something like this:

cd c:\test\ReadCodes
echo "select * from readcode where read_code glob 'G2*'" |
c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db > testfile.txt

Derrell


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] select from commandprompt with output to file

2006-11-17 Thread Dan Kennedy

What sqlite versions, OS etc.? This worked for me:

$ sqlite3
SQLite version 3.2.8
Enter ".help" for instructions
sqlite> create table abc(a, b, c);
sqlite> .output out.txt
sqlite> select * from sqlite_master;
sqlite> .quit 
$ cat out.txt
table|abc|abc|2|CREATE TABLE abc(a, b, c)


> 
> How do I do this:
> From the command prompt issue a simple select query to a specified database
> and direct the output to a file.
> I can see there is the .output FILENAME option, but nothing seems to happen.
> .output stdout works fine with output to the screen.
> Must be overlooking something simple here.
> 
> RBS
> 
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
> 
> 



 

Sponsored Link

$200,000 mortgage for $660/ mo - 
30/15 yr fixed, reduce debt - 
http://yahoo.ratemarketplace.com

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] select from commandprompt with output to file

2006-11-16 Thread Derrell . Lipman
"RB Smissaert" <[EMAIL PROTECTED]> writes:

> How would I run these 4 commands via a .bat file or via whatever means:
>
> cd c:\test\ReadCodes
> c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db"
> .output testfile.txt
> select * from readcode where read_code glob 'G2*';

I haven't been tracking this thread so apologies if I'm misunderstanding what
you want.  Are you doing this from a DOS (Command) shell?  I'm far from a DOS
expert, but how about something like this:

cd c:\test\ReadCodes
echo "select * from readcode where read_code glob 'G2*'" | 
c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db > testfile.txt

Derrell

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] select from commandprompt with output to file

2006-11-16 Thread RB Smissaert
Kees,

How would I run these 4 commands via a .bat file or via whatever means:

cd c:\test\ReadCodes
c:\test\Program\sqlite3 c:\test\ReadCodes\ReadCode.db"
.output testfile.txt
select * from readcode where read_code glob 'G2*';

It must be simple, but I can't see it.

RBS

-Original Message-
From: Kees Nuyt [mailto:[EMAIL PROTECTED] 
Sent: 16 November 2006 21:36
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] select from commandprompt with output to file


Hi RBS,

On Thu, 16 Nov 2006 19:56:36 -, you wrote:

>How do I do this:
>From the command prompt issue a simple select query to a specified database
>and direct the output to a file.
>I can see there is the .output FILENAME option, but nothing seems to
happen.
>.output stdout works fine with output to the screen.
>Must be overlooking something simple here.
>
>RBS

.output FILENAME 
doesn't do anything by itself, it only sets the name of the file
any follwing commands will write output to.
Once you execute a query afterwards the file should be created.
If you want the file in another directory than the current one,
use slashes in the path, not backslashes.

The following code works for me:

C:\DATA\opt\test>sqlite3 tmp/test.db3
SQLite version 3.3.8
Enter ".help" for instructions
sqlite> .mode list
sqlite> .headers off
sqlite> .output tmp/master.html
sqlite> SELECT 'Database schema';
sqlite> SELECT 'Report on database schema TESTtables';
sqlite> .mode html
sqlite> .headers on
sqlite> select * from sqlite_master order by type,name;
sqlite> .mode list
sqlite> .headers off
sqlite> SELECT '';
sqlite> .q

C:\DATA\opt\test>
-- 
  (  Kees Nuyt
  )
c[_]


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] select from commandprompt with output to file

2006-11-16 Thread RB Smissaert
Hi Kees,

Not sure what I did wrong, but I got it working now.
Just wondering now if I actually need the VB wrapper. Looks all can be done
with command-line work.

RBS

-Original Message-
From: Kees Nuyt [mailto:[EMAIL PROTECTED] 
Sent: 16 November 2006 21:36
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] select from commandprompt with output to file


Hi RBS,

On Thu, 16 Nov 2006 19:56:36 -, you wrote:

>How do I do this:
>From the command prompt issue a simple select query to a specified database
>and direct the output to a file.
>I can see there is the .output FILENAME option, but nothing seems to
happen.
>.output stdout works fine with output to the screen.
>Must be overlooking something simple here.
>
>RBS

.output FILENAME 
doesn't do anything by itself, it only sets the name of the file
any follwing commands will write output to.
Once you execute a query afterwards the file should be created.
If you want the file in another directory than the current one,
use slashes in the path, not backslashes.

The following code works for me:

C:\DATA\opt\test>sqlite3 tmp/test.db3
SQLite version 3.3.8
Enter ".help" for instructions
sqlite> .mode list
sqlite> .headers off
sqlite> .output tmp/master.html
sqlite> SELECT 'Database schema';
sqlite> SELECT 'Report on database schema TESTtables';
sqlite> .mode html
sqlite> .headers on
sqlite> select * from sqlite_master order by type,name;
sqlite> .mode list
sqlite> .headers off
sqlite> SELECT '';
sqlite> .q

C:\DATA\opt\test>
-- 
  (  Kees Nuyt
  )
c[_]


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] select from commandprompt with output to file

2006-11-16 Thread Kees Nuyt

Hi RBS,

On Thu, 16 Nov 2006 19:56:36 -, you wrote:

>How do I do this:
>From the command prompt issue a simple select query to a specified database
>and direct the output to a file.
>I can see there is the .output FILENAME option, but nothing seems to happen.
>.output stdout works fine with output to the screen.
>Must be overlooking something simple here.
>
>RBS

.output FILENAME 
doesn't do anything by itself, it only sets the name of the file
any follwing commands will write output to.
Once you execute a query afterwards the file should be created.
If you want the file in another directory than the current one,
use slashes in the path, not backslashes.

The following code works for me:

C:\DATA\opt\test>sqlite3 tmp/test.db3
SQLite version 3.3.8
Enter ".help" for instructions
sqlite> .mode list
sqlite> .headers off
sqlite> .output tmp/master.html
sqlite> SELECT 'Database schema';
sqlite> SELECT 'Report on database schema TESTtables';
sqlite> .mode html
sqlite> .headers on
sqlite> select * from sqlite_master order by type,name;
sqlite> .mode list
sqlite> .headers off
sqlite> SELECT '';
sqlite> .q

C:\DATA\opt\test>
-- 
  (  Kees Nuyt
  )
c[_]

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] select from commandprompt with output to file

2006-11-16 Thread RB Smissaert

How do I do this:
>From the command prompt issue a simple select query to a specified database
and direct the output to a file.
I can see there is the .output FILENAME option, but nothing seems to happen.
.output stdout works fine with output to the screen.
Must be overlooking something simple here.

RBS



-
To unsubscribe, send email to [EMAIL PROTECTED]
-