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] 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] INSERT is corrupting a database

2017-01-12 Thread Jens Alfke

> On Jan 12, 2017, at 3:52 PM, Kevin O'Gorman  wrote:
> 
> My opinion is that no user bug whatever should cause DB integrity problems
> without raising an exception.

That is a totally reasonable attitude … for programs running in a “safe” 
environment like an interpreter.
However, in the world of low-level native code, there’s nothing SQLite can do 
about a C program overwriting parts of its data structures or file buffers.

Granted, Clemens’ program is written in Python, a “safe” environment, so it 
shouldn’t be able to corrupt a database. There might be a bug in Python’s 
SQLite glue code, though.

—Jens
___
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-12 Thread Kevin O'Gorman
On Tue, Jan 10, 2017 at 7:52 PM, Simon Slavin  wrote:

>
> On 11 Jan 2017, at 3:28am, Kevin O'Gorman  wrote:
>
> > I have a modest amount of data that I'm loading into an SQLite database
> for
> > the first time.  For the moment it contains just two tables and a few
> > indices, nothing else.  The first table loads okay, and if I stop the
> > process at that point, all is well and I can look at the database.
> >
> > 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.
>
> Make absolutely sure you’re starting with a new database file each time,
> not continuing to write to an already-corrupt file.
>
> I'm sure.  The program tests for the existence of the main table before
starting, and throws an exception if it's there, then creates that table as
its first action.


> At stages during your Python program, including after you’ve finished
> loading the first table, use the following command to check to see whether
> the database is correct:
>
> It's no longer possible.  In fixing other things, the program has changed,
and it no longer corrupts the database.  Thanks for this next thing,
though



> PRAGMA integrity_check
>

Thanks for that.  I was not aware of this tool.  I'll keep it handy.


> Use the same command in the command-line tool.
>
> Simon.
>

-- 
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] INSERT is corrupting a database

2017-01-12 Thread Kevin O'Gorman
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.


> > If however, I split the program into two programs, one for each table,
> and
> > run them one after another, all is well.  Same code, each with parts of
> it
> > if-else-ed out.
>
> 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.




-- 
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] INSERT is corrupting a database

2017-01-10 Thread Clemens Ladisch
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?

> If however, I split the program into two programs, one for each table, and
> run them one after another, all is well.  Same code, each with parts of it
> if-else-ed out.

It's possible that there is a bug in your code.  Which you have not shown.


Regards,
Clemens
___
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-10 Thread Simon Slavin

On 11 Jan 2017, at 3:28am, Kevin O'Gorman  wrote:

> I have a modest amount of data that I'm loading into an SQLite database for
> the first time.  For the moment it contains just two tables and a few
> indices, nothing else.  The first table loads okay, and if I stop the
> process at that point, all is well and I can look at the database.
> 
> 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.

Make absolutely sure you’re starting with a new database file each time, not 
continuing to write to an already-corrupt file.

At stages during your Python program, including after you’ve finished loading 
the first table, use the following command to check to see whether the database 
is correct:

PRAGMA integrity_check

Use the same command in the command-line tool.

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