Re: [sqlite] Null returned from NOT NULL column thanks to undetected corruption

2017-01-13 Thread Rowan Worth
On 13 January 2017 at 22:59, David Raymond  wrote:

> My view is that the general thinking of the program here is simply: "just
> don't make things worse." It can't help what pragmas (ie
> ignore_check_constraints, writable_schema etc) others may have turned on
> for their connections, or what sort of junk was there when it arrived.


ignore_check_constraints doesn't seem to affect NOT NULL constraints:

  sqlite> create table a(b INTEGER NOT NULL);
  sqlite> insert into a values(NULL);
  Error: NOT NULL constraint failed: a.b
  sqlite> pragma ignore_check_constraints = 1;
  sqlite> insert into a values(NULL);
  Error: NOT NULL constraint failed: a.b

I can't see any pragmas that do? writable_schema is fair, but the
advertised procedure[1] _does_ come with the warning that a mistake using
it will corrupt your database. It's not entirely unreasonable to classify
"using writable_schema to add a NOT NULL constraint to a column without
ensuring all rows are NOT NULL" as a mistake. I also agree that calling the
result corrupted is not an ideal result, but it provides benefits in the
form of sanity checks elsewhere.

[1] https://www.sqlite.org/lang_altertable.html#otheralter

I haven't figured out any other way to get a NULL value into a NOT NULL
column. The regular ALTER TABLE command refuses:

  sqlite> alter table a add column c INTEGER NOT NULL;
  Error: Cannot add a NOT NULL column with default value NULL

Nor does sqlite allow them to propagate from tables affected by truncation
as in my original post:

  sqlite> create table table2 (C INTEGER NOT NULL);
  sqlite> insert into table2 select a from test_table;
  Error: NOT NULL constraint failed: table2.C

As to the truncated page it would be kind of bad for it to say "hey,
> someone else corrupted 28 bytes, so I won't give you info on the other 99%
> that I can read just fine." All that being said though it might be nice to
> know there was a noticed issue.
>

I don't buy this one at all. Especially as sqlite fills pages backwards
(starting from the end), so a truncated page almost certainly represents
lost user data. I can't see anything in the hardware assumptions[2] to
suggest a truncated page is ever a valid configuration.

[2] https://www.sqlite.org/atomiccommit.html#hardware

It does clarify that sqlite goes to no effort to detect bit errors and the
like, but again I'm not asking for checksums or error correction codes. It
also says "SQLite assumes that the data it reads is exactly the same data
that it previously wrote". I'm pretty sure it never does any write that is
not a multiple of the page size, so a short read due to EOF is a pretty
good indication that this assumption has been violated!


> Also, quietly dealing with a different number of fields found in the file
> compared to what it parsed from the schema is how it handles "alter table
> add column" without needing to rewrite the entire table when you do that.
> That might also explain why you can see nulls for fields that got
> truncated.


Nope, see above. If you can provide me a legitimate way to violate a NOT
NULL constraint then I'll happily concede that the presence of a NULL cell
cannot be trusted as an indicator of corruption, but so far all my attempts
have failed. And at this stage no I don't consider shooting yourself in the
foot with writable_schema a legitimate way :P

I've been testing with 3.14.2 - if it was possible/easier in previous
versions to violate NOT NULL then backwards compatibility may also rule
this out.

-Rowan



  sqlite3 test.db "CREATE TABLE test_table (A INT4 NOT NULL, B INT4 NOT
> NULL);"
>  for N in `seq 1 10`
>  do
>  sqlite3 test.db "INSERT INTO test_table (A, B) VALUES ($N, $N);"
>  done
>
>  dd if=test.db of=cropped.db bs=2020 count=1
>  sqlite3 cropped.db "SELECT * FROM test_table;"
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] does integrity check ever modify the db file?

2017-01-13 Thread Rowan Worth
On 14 January 2017 at 03:51, Adam Smith  wrote:

> Hey all,
>   can 'pragma integrity_check' ever modify the file? For instance in case
> of a journal file laying around (which was journal file of the same schema
> db but a bit different data)?
>
> The following is what I think happened:
>
> a.db and b.db are two sqlite dbs of size ~5mb which have same schema and
> little difference in data.
> the process writing to a.db is terminated or power loss or something so
> a-journal.db left behind.
> >> ls
> a.db
> a-journal.db
> b.db
> >> sqlite3 b.db 'pragma integrity_check'# b.db is healthy
> ok
> >> rm a.db
> >> mv b.db a.db  # rename b.db as a.db
> >> sqlite3 a.db 'pragma integrity_check'   # this is I think when integrity
> check modifies a.db and corrupts it
> failure
> >> ls
> a.db
> >> sqlite3 a.db 'pragma integrity_check'
> failure...
>
>
> a.db is corrupted
>
> Is this possible? If so how do we delete all temp files like -journal file?
> Thanks in advance
>

Yes and no. Integrity_check itself never modifies the the database file.
However, in the situation you describe the file _can_ be modified as a side
effect of reading the database (which of course integrity_check needs to
do).

The -journal file is a rollback journal - it contains the original content
of database pages before the transaction began. The scenario above arises
if power is lost while a transaction is only partway committed. Sqlite has
modified some of the database pages on disk but not necessarily all -- ie.
the main database file might not be consistent. The implication here is
that the main database file is not safe to access by itself in this state.

If you try to query an sqlite database in this state, it will notice that
there is a "hot" journal and rollback the partial transaction (by copying
the original page data stored in the rollback journal back into the
database).

From your description it looks like that's what happened here. You've run a
query (integrity_check) against the copied database, and sqlite has noticed
the -journal file, concluded that something must have gone wrong in the
middle of a transaction (correct), and rolled back the changes that
transaction made. Only problem is the partial transaction was against a
different database (the original a.db, not the copy of b.db) so the
rollback resulted in a corrupt state.

For more details see:
https://www.sqlite.org/howtocorrupt.html#_deleting_a_hot_journal
https://www.sqlite.org/atomiccommit.html#_deleting_or_renaming_a_hot_journal

Deleting a -journal file is not advisable in general because it contains
important information for ensuring the database is in a consistent state,
but when you're trying to delete an entire database it makes sense. The
list of possible files associated with an sqlite database is described here:

https://www.sqlite.org/tempfiles.html

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


Re: [sqlite] Insert into with Id...

2017-01-13 Thread hfiandor
Dear Mr. Simon Slavin:

I have implemented the lectura of a csv file in my program as "import". I have 
followed yours instructions (the last one and others previous) . Thanks for 
your instructions.

The program works fine with csv files of one or two rows, but when I try to 
read a file with 9 rows, it fails.

I have reviewed the routines and not found the errors.

Please, I suspect that I have missed something. If you have any suggestion, I 
will appreciate very much.

If you need the procedure "import" I can send to you.

Thanks in advance,

Ing. Héctor F. Fiandor Rosario

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


[sqlite] Multiple sessions, page sizes and cache

2017-01-13 Thread Kim Gräsman
Hi all,

We have an application with multiple databases of different page
sizes. We keep a few long-running sessions, but also open transient
sessions occasionally.

In an effort to reduce memory usage/fragmentation, we're trying to
configure SQLite to allocate as much memory as necessary up-front
(based on the excellent information in
https://www.sqlite.org/malloc.html).

Naively, I would expect SQLite to allocate a page cache per session.
But reading the documentation, it sounds like there's only one page
cache buffer, shared between all sessions.

So if we want to use SQLITE_CONFIG_PAGECACHE to provide a
preallocated buffer for the page cache, it looks like we have to
provide it for the worst case, i.e. max(page size) * sum(cache
requirements for all sessions). Is that the case?

Moreover, if SQLITE_CONFIG_PAGECACHE is under-allocated, the docs say
SQLite goes to malloc (or some variety thereof):

> If SQLite needs a page-cache entry that is larger than "sz" bytes or if it 
> needs more than N entries,
> it falls back to using the general-purpose memory allocator.
https://www.sqlite.org/malloc.html#_page_cache_memory

and:

> If additional page cache memory is needed beyond what is provided by this 
> option, then
> SQLite goes to sqlite3_malloc() for the additional storage space.
https://www.sqlite.org/c3ref/c_config_getmalloc.html#sqliteconfigpagecache

Does it do this for every page that doesn't fit, or just up-front to
allocate a page cache block? That is, is SQLITE_CONFIG_PAGECACHE used
to specify an arena for page caches, or a buffer for pages between all
sessions?

Since we have different page sizes (512 bytes and 4K respectively) I'm
worried we'll have lots of dead space if SQLITE_CONFIG_PAGECACHE is
set up for 4K pages and requests for 512-byte pages are served from
there directly.

Many thanks,
- Kim
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] does integrity check ever modify the db file?

2017-01-13 Thread Adam Smith
Hey all,
  can 'pragma integrity_check' ever modify the file? For instance in case
of a journal file laying around (which was journal file of the same schema
db but a bit different data)?

The following is what I think happened:

a.db and b.db are two sqlite dbs of size ~5mb which have same schema and
little difference in data.
the process writing to a.db is terminated or power loss or something so
a-journal.db left behind.
>> ls
a.db
a-journal.db
b.db
>> sqlite3 b.db 'pragma integrity_check'# b.db is healthy
ok
>> rm a.db
>> mv b.db a.db  # rename b.db as a.db
>> sqlite3 a.db 'pragma integrity_check'   # this is I think when integrity
check modifies a.db and corrupts it
failure
>> ls
a.db
>> sqlite3 a.db 'pragma integrity_check'
failure...


a.db is corrupted

Is this possible? If so how do we delete all temp files like -journal file?
Thanks in advance
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQLite installation query

2017-01-13 Thread Saurabh Sukhani
Dear Members,

I am trying to install SQLite in my Windows 10 machine. I want to use
SQLite database for my project. The target framework is .net 4.0 and am
using VS 2010.

SQLite .NET download page has the following:

Setups for 64-bit Windows (.NET Framework 4.0)
*sqlite-netFx40-setup-bundle-**x64-2010-1.0.104.0.exe* (14.27 MiB) This
setup package features the mixed-mode assembly and will install all the
necessary runtime components and dependencies for the x64 version of the
System.Data.SQLite 1.0.104.0 (3.15.2) package.

*sqlite-netFx40-setup-x64-2010-**1.0.104.0.exe* (14.26 MiB) This setup
package will install all the necessary runtime components and dependencies
for the x64 version of the System.Data.SQLite 1.0.104.0 (3.15.2) package.

When I am installing using sqlite-netFx40-setup-x64-2010-1.0.104.0.exe and
using SQLite in my project then I get error "Unable to load DLL
'SQLite.Interop.dll': The specified module could not be found. (Exception
from HRESULT: 0x8007007E)". To solve it I have to copy the interop dll file
in the debug folder.

However when I install using sqlite-netFx40-setup-bundle-x64-2010-1.0.104.0.exe
then I can run my program without the need for interop dll. It does not
give any error and only System.Data.SQLite.dll is needed.

I wonder why is this happening ? Infact there is no interop dll in the
former installation.

I will be glad if anyone can help me.
Regards,
Saurabh
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] subscribe

2017-01-13 Thread Adam Smith

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


Re: [sqlite] extension to run bash

2017-01-13 Thread James K. Lowden
On Thu, 12 Jan 2017 01:54:28 +
Roman Fleysher  wrote:

> From bash script, make list of rows, run commands, load results to
> sqlite. Or
> 
> From sqlite, use extension to run commands for each row.
> 
> Both have issues.

You will find your shell script faster.  The more files, the more it
matters.  That's because (presumably) your script invokes wc(1) once,
and that process iterates over the filenames.  The longer your
pipeline, the more the process is parallelized, too.  

You could also use make(1) to maintain aggregate counts.  Imagine
roughly a rule like this:

.txt.N:
wc $^ > $@

Re-run make at convenient intervals, and let it determine which counts
are out of date.  The more files, the bigger, and the more static they
are, the more make saves you.  

If you use an extension, every row gets a process.  If you use 
system(3) instead of exec(2), every row gets two processes.  Each row's
process (or two) has to run sequentially.  That will add up.  

The advantage of the extension is that it's a "view"; the data are as
good as the time the query is run.  (We're giving up atomicity, because
nothing prevents the files from being changed as the query runs.)  

To make the extension faster -- as fast as the script would be -- you
can't run one process per row.  Instead, implement wc(1) as a C
function, and create a wc extension.  Instead of writing the code
yourself, I'd steal an implementation.  NetBSD's wc.c is 354 lines,
half of which is copyright & UI.  

A "wc" extension would be simpler than a "system" extension.  Once
you've written your first one, you'll find doing others is easy.
Before you know it, you'll have a little collection of /usr/bin-like
extensions that do what you need.  They'll be faster as fast as
anything the shell does (modulo parallel execution) and more convenient
because you'll do everything in SQL.  

In case it's any help, I implemented an extension a while back that
calls stat(2), cf. http://www.schemamania.org/sql/sqlite/udf/.  Look
for "File Metadata" halfway down the page.  

HTH.  

--jkl


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


Re: [sqlite] Problem with compiled dll on Windows

2017-01-13 Thread James K. Lowden
On Wed, 11 Jan 2017 10:46:51 -0800
Random Coder  wrote:

> Normally, I'd say this is toolset knowledge, and really doesn't
> belong in those sort of directions.  But since you're not the first
> person to hit this problem

Having dealt with the problem of other-system support on a smaller
scale for a decade, I would advise against providing any support for
issues not specific to SQLite.  The folks who develop SQLite know more
than anyone else about SQLite, but they have no special knowledge of
how to build Windows binaries.  Any advice is apt to be incomplete,
possibly misleading, and will easily fall out of date (especially wrt
Windows).  

That doesn't have to mean no help at all.  If the project wants to
supply a Makefile suitable for NMAKE, for example, then of course it
should document how that's used and what it does.  But someone who
isn't using the tool correctly and is getting a bad result is better
served by basically suggesting RTFM, because that's where the right
answers are to be found.  

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


Re: [sqlite] Null returned from NOT NULL column thanks to undetected corruption

2017-01-13 Thread James K. Lowden
On Fri, 13 Jan 2017 11:17:11 +0800
Rowan Worth  wrote:

> I wonder if this is something sqlite could catch in normal operation
> and return SQLITE_CORRUPT? Or are there reasons/history which would
> render this conclusion inaccurate?

Not without cost.  

In general, it's difficult for any program to verify the integrity of a
file.  One way would be to keep a checksum of some kind in the file,
and update it whenever the file is closed.  That imposes the cost of
validating the checksum when the file is opened, and of computing it
when it's closed.  And the cost of a false positive: perhaps the data
are OK, but the checksum was corrupted.  

A checksum like that couldn't be added to SQLite without changing the
file format, which has been fixed for over a decade.  

The guard against FTP truncation is well known.  Transfer the file to a
temporary name, and rename it to its proper name only when the transfer
is successfully concluded.  TCP ensures reliable delivery; only a bug
in the FTP program (or underlying software or hardware) could introduce
data corruption. 

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


Re: [sqlite] INSERT is corrupting a database

2017-01-13 Thread Kevin O'Gorman
On Fri, Jan 13, 2017 at 3:34 AM, Clemens Ladisch  wrote:

> Kevin O'Gorman wrote:
> > On Tue, Jan 10, 2017 at 11:29 PM, Clemens Ladisch 
> wrote:
> >> Kevin O'Gorman wrote:
> >>> If I go on to the second table, it appears to finish normally, but
> when I
> >>> try to look at the database with sqlite3, a command-line tool for
> >>> interacting with SQLite, it says the database is corrupt.
> >>
> >> What version?
> >
> > It's whatever is in Python 3.5.2.'s builtin sqlite package.
>
> The sqlite3 command-line shell does not ship with Python.
>
> >> It's possible that there is a bug in your code.  Which you have not
> shown.
> >
> > My opinion is that no user bug whatever should cause DB integrity
> problems without
> > raising an exception.
>
> 
> But it's unlikely that you'd manage to do any of this in Python.
>
> Anyway, my own test program works.
>

That's twisted backwards.

My database builder is built with pure Python, using the SQLite package
that comes with it.  Then sqlite3 just refuses to open the result.  That's
just what's in the Xubuntu 16.04 repos, i.e. version 3.11.0-1ubuntu1; I
didn't report that because I don't suspect sqlite3 of being a cause.
Indeed, it was changes to the python code that seems to have stopped
provoking the error -- nothing about squlite3 has changed.  Anyway, I did
not save the problem code, so I can no longer pursue this.

-- 
word of the year: *kakistocracy*
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Null returned from NOT NULL column thanks to undetected corruption

2017-01-13 Thread David Raymond
My view is that the general thinking of the program here is simply: "just don't 
make things worse." It can't help what pragmas (ie ignore_check_constraints, 
writable_schema etc) others may have turned on for their connections, or what 
sort of junk was there when it arrived. In its head it's going to hear its 
Mom's voice saying "if all the other kids were ignoring not null constraints, 
would you?" and simply not let you add new errors. As to the truncated page it 
would be kind of bad for it to say "hey, someone else corrupted 28 bytes, so I 
won't give you info on the other 99% that I can read just fine." All that being 
said though it might be nice to know there was a noticed issue.

Remember that with the select you're asking it to tell you what "is" in there, 
not what "should" be in there. Also, quietly dealing with a different number of 
fields found in the file compared to what it parsed from the schema is how it 
handles "alter table add column" without needing to rewrite the entire table 
when you do that. That might also explain why you can see nulls for fields that 
got truncated.

So I suppose what it comes down to then is whether it should return OK, or some 
other code that says "I did what you told me, but I found a problem that wasn't 
so bad that it keep me from completing my task"



(Apologies for those who won't get the following reference from my psychotic 
mind)

create table objects (object_type, object_location,
  check (case object_location when 'out on the wing' then object_type = 
'nothing' else 1 end));

select * from objects where object_location = 'out on the wing';
object_type|object_location
something|out on the wing

Should that return SQLITE_OK, SQLITE_CORRUPT or 
SQLITE_UHH_SOMETHINGS_NOT_QUITE_RIGHT_HERE ?

Or should it have looked at the check constraint and just returned...

object_type|object_location
nothing|out on the wing

...despite it seeing...

object_type|object_location
something|out on the wing

...because it just shouldn't exist.

-Original Message-
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Rowan Worth
Sent: Thursday, January 12, 2017 10:17 PM
To: General Discussion of SQLite Database
Subject: [sqlite] Null returned from NOT NULL column thanks to undetected 
corruption

Hi guys,

Ran into an interesting situation recently where a database was transferred
via FTP and the client somehow managed to truncate the file. As a result
the last page was only 337 bytes rather than the expected 1024.
Surprisingly running a SELECT on the affected table works without sqlite
returning any error!

However several of the returned rows are completely blank, despite 7 out of
8 columns having a NOT NULL constraint. Anyway we came up with a simple
reproducer:


 sqlite3 test.db "CREATE TABLE test_table (A INT4 NOT NULL, B INT4 NOT
NULL);"
 for N in `seq 1 10`
 do
 sqlite3 test.db "INSERT INTO test_table (A, B) VALUES ($N, $N);"
 done

 dd if=test.db of=cropped.db bs=2020 count=1
 sqlite3 cropped.db "SELECT * FROM test_table;"


Which produces results:

|
|
|
|
0|0
6|6
7|7
8|8
9|9
10|10

test.db is two pages long, so the truncation here is only 28 bytes. I
realise that some types of corruption are too small to notice without some
kind of checksum/error checking code, which feels a bit heavyweight for the
general case. But here it seems like there are some pretty significant red
flags:

1. the database contains an incomplete page
2. a NOT NULL column contains a NULL cell

"PRAGMA integrity_check" does flag problems with cropped.db, but because of
these two conditions I wonder if this is something sqlite could catch in
normal operation and return SQLITE_CORRUPT? Or are there reasons/history
which would render this conclusion inaccurate?

I notice that if I modify the database and another page gets added, sqlite
*does* start returning SQLITE_CORRUPT so I wonder if there's something
special about the last page?
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] INSERT is corrupting a database

2017-01-13 Thread Clemens Ladisch
Kevin O'Gorman wrote:
> On Tue, Jan 10, 2017 at 11:29 PM, Clemens Ladisch  wrote:
>> Kevin O'Gorman wrote:
>>> If I go on to the second table, it appears to finish normally, but when I
>>> try to look at the database with sqlite3, a command-line tool for
>>> interacting with SQLite, it says the database is corrupt.
>>
>> What version?
>
> It's whatever is in Python 3.5.2.'s builtin sqlite package.

The sqlite3 command-line shell does not ship with Python.

>> It's possible that there is a bug in your code.  Which you have not shown.
>
> My opinion is that no user bug whatever should cause DB integrity problems 
> without
> raising an exception.


But it's unlikely that you'd manage to do any of this in Python.

Anyway, my own test program works.


Regards,
Clemens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Exiting SQLite3 from within a (.bat) file

2017-01-13 Thread tbuck...@frontier.com
Thank you.That works great.Tom...
 

On Friday, January 13, 2017 9:46 AM, Kees Nuyt  wrote:
 

 On Fri, 13 Jan 2017 08:12:33 + (UTC),
"tbuck...@frontier.com"  wrote:

> Hello,I have a batch (.bat) file that runs a C program to
> pre-process a text file to a clean .csv file. 
> Then the batch file runs SQLite3 -init to execute dot (.)
> commands.  Everything works great except the last dot
> command ".exit" or ".quit" to close the SQLite3 program
> out.  I always have to manually enter .exit to get back
> to the command prompt.  What can I do to have SQLite3
> automatically exit?

> The batch file has the following commands:
>  cls
>  SOE_sort.exe %1
>  sqlite3.exe -init SOE_sortRC.sqliterc

Try:
  cls
  SOE_sort.exe %1
  sqlite3.exe https://www.sqlite.org/src/artifact?name=6095531aa900decd=5634-5650

A script as redirected input _does_ execute .quit, it even exits
without .quit when the stream reaches end of file.

-- 
Regards,

Kees Nuyt

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


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


Re: [sqlite] Exiting SQLite3 from within a (.bat) file

2017-01-13 Thread Kees Nuyt
On Fri, 13 Jan 2017 08:12:33 + (UTC),
"tbuck...@frontier.com"  wrote:

> Hello,I have a batch (.bat) file that runs a C program to
> pre-process a text file to a clean .csv file. 
> Then the batch file runs SQLite3 -init to execute dot (.)
> commands.  Everything works great except the last dot
> command ".exit" or ".quit" to close the SQLite3 program
> out.  I always have to manually enter .exit to get back
> to the command prompt.  What can I do to have SQLite3
> automatically exit?

> The batch file has the following commands:
>   cls
>   SOE_sort.exe %1
>   sqlite3.exe -init SOE_sortRC.sqliterc

Try:
   cls
   SOE_sort.exe %1
   sqlite3.exe https://www.sqlite.org/src/artifact?name=6095531aa900decd=5634-5650

A script as redirected input _does_ execute .quit, it even exits
without .quit when the stream reaches end of file.

-- 
Regards,

Kees Nuyt

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


[sqlite] Exiting SQLite3 from within a (.bat) file

2017-01-13 Thread tbuck...@frontier.com
Hello,I have a batch (.bat) file that runs a C program to pre-process a text 
file to a clean .csv file.  Then the batch file runs SQLite3 -init to execute 
dot (.) commands.  Everything works great except the last dot command ".exit" 
or ".quit" to close the SQLite3 program out.  I always have to manually enter 
.exit to get back to the command prompt.  What can I do to have SQLite3 
automatically exit?
The batch file has the following commands:cls
SOE_sort.exe %1
sqlite3.exe -init SOE_sortRC.sqliterc

Thanks,
Tom...
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users