Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Pavel Ivanov
> Is it possible to check even if a db file exists and if necessary create it
> from within c++ ?
> So I would open the db file  sqlite3_open("ah.db", &db);   only if it really
> exists ..

Why do you need to create file from C++? If file doesn't exist SQLite
will automatically create it for you after sqlite3_open().

Pavel


On Tue, Jun 26, 2012 at 12:27 PM, deltagam...@gmx.net
 wrote:
> Am 26.06.2012 18:00, schrieb Pavel Ivanov:
>
>> On Tue, Jun 26, 2012 at 11:50 AM, deltagam...@gmx.net
>>  wrote:
>>>
>>> Am 26.06.2012 17:08, schrieb Pavel Ivanov:
>>>
 You are leaking stmt statement (re-preparing without finaliznig) and
 your call to sqlite3_close returns SQLITE_ERROR because of that, but
 you don't even check that so you are leaking database connections as
 well.

 Pavel


 On Tue, Jun 26, 2012 at 11:01 AM, deltagam...@gmx.net
  wrote:
>
> Am 26.06.2012 16:49, schrieb Richard Hipp:
>
>> On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
>> wrote:
>>
>>> I have a c++ GUI application from where the db is read and the
>>> content
>>> is
>>> displayed in a Clistbox.
>>> Then I try to delete some rows from the sqlite3-db from the console.
>>> After rereading from within the GUI the deleted rows are still there.
>>>
>>> How is this possible ?
>>>
>> The GUI is holding a read transaction open.  Hence it sees a
>> consistent
>> snapshot of the database from the moment in time when the transaction
>> was
>> started.  Subsequent writes to the database are ignored by the GUI
>> until
>> it
>> closes its current transaction and starts a new one.
>>
>>
>>
>>>
> First, I would like to thank all for the great support, a special thanks to
> Pavel Ivanov and Richard Hipp
>
> I think with
> ==
>
>    char create_sql[] = "CREATE TABLE if not exists eventlog ("
>        "id INTEGER PRIMARY KEY,"
>        "eventdate DATETIME default current_timestamp,"
>        "eventtype TEXT,"
>        "counter INTEGER"
>        ")";
> rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);
> =
> it is a convenient way to check if a table exists.
>
> Is it possible to check even if a db file exists and if necessary create it
> from within c++ ?
> So I would open the db file  sqlite3_open("ah.db", &db);   only if it really
> exists ..
>
>
>
> ___
> 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] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Simon Slavin

On 26 Jun 2012, at 5:27pm, deltagam...@gmx.net wrote:

> Is it possible to check even if a db file exists and if necessary create it 
> from within c++ ?
> So I would open the db file  sqlite3_open("ah.db", &db);   only if it really 
> exists ..

Look at the flags available to the _open_v2() function:



I think you want SQLITE_OPEN_READONLY .

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


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread deltagam...@gmx.net

Am 26.06.2012 18:00, schrieb Pavel Ivanov:

On Tue, Jun 26, 2012 at 11:50 AM, deltagam...@gmx.net
 wrote:

Am 26.06.2012 17:08, schrieb Pavel Ivanov:


You are leaking stmt statement (re-preparing without finaliznig) and
your call to sqlite3_close returns SQLITE_ERROR because of that, but
you don't even check that so you are leaking database connections as
well.

Pavel


On Tue, Jun 26, 2012 at 11:01 AM, deltagam...@gmx.net
 wrote:

Am 26.06.2012 16:49, schrieb Richard Hipp:


On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
wrote:


I have a c++ GUI application from where the db is read and the content
is
displayed in a Clistbox.
Then I try to delete some rows from the sqlite3-db from the console.
After rereading from within the GUI the deleted rows are still there.

How is this possible ?


The GUI is holding a read transaction open.  Hence it sees a consistent
snapshot of the database from the moment in time when the transaction
was
started.  Subsequent writes to the database are ignored by the GUI until
it
closes its current transaction and starts a new one.





First, I would like to thank all for the great support, a special thanks 
to Pavel Ivanov and Richard Hipp


I think with
==
char create_sql[] = "CREATE TABLE if not exists eventlog ("
"id INTEGER PRIMARY KEY,"
"eventdate DATETIME default current_timestamp,"
"eventtype TEXT,"
"counter INTEGER"
")";
rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);
=
it is a convenient way to check if a table exists.

Is it possible to check even if a db file exists and if necessary create 
it from within c++ ?
So I would open the db file  sqlite3_open("ah.db", &db);   only if it 
really exists ..



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


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Pavel Ivanov
On Tue, Jun 26, 2012 at 11:50 AM, deltagam...@gmx.net
 wrote:
> Am 26.06.2012 17:08, schrieb Pavel Ivanov:
>
>> You are leaking stmt statement (re-preparing without finaliznig) and
>> your call to sqlite3_close returns SQLITE_ERROR because of that, but
>> you don't even check that so you are leaking database connections as
>> well.
>>
>> Pavel
>>
>>
>> On Tue, Jun 26, 2012 at 11:01 AM, deltagam...@gmx.net
>>  wrote:
>>>
>>> Am 26.06.2012 16:49, schrieb Richard Hipp:
>>>
 On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
 wrote:

> I have a c++ GUI application from where the db is read and the content
> is
> displayed in a Clistbox.
> Then I try to delete some rows from the sqlite3-db from the console.
> After rereading from within the GUI the deleted rows are still there.
>
> How is this possible ?
>
 The GUI is holding a read transaction open.  Hence it sees a consistent
 snapshot of the database from the moment in time when the transaction
 was
 started.  Subsequent writes to the database are ignored by the GUI until
 it
 closes its current transaction and starts a new one.



>>>
> 
> void InitialReadEventsData()
>
> {
>
>    // Remove all events from array
>    m_arrEvents.RemoveAll();
>
>    // write  events
>    Event newEvent;
>
> // sqlite3 reading ///
>
>        int rc, id, total_events;
>        char *sql, *sqltotal;
>        char *evdate, *evtype;
>        int evctr;
>
>        int the_event_ctr = 0;
>
>        CString datetime;
>        CString datepart;
>        CString timepart;
>
>
>        sqlite3 *db;
>        sqlite3_stmt *stmt;
>
>        sqlite3_open("ah.db", &db);
> /*
>
>    // check if table eventlog exists
>    char create_sql[] = "CREATE TABLE if not exists eventlog ("
>        "id INTEGER PRIMARY KEY,"
>        "eventdate DATETIME default current_timestamp,"
>        "eventtype TEXT,"
>        "counter INTEGER"
>        ")";
>
>    rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);
>
>
> */
>
>
>    // select count(*) from eventlog
>    sqltotal = "Select count(*) from eventlog";
>    rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
>    rc = sqlite3_step(stmt);
>    total_events = sqlite3_column_int(stmt, 0 );
>
>    std::cout << total_events << std::endl;
>
>
>
>    // select * from eventlog
>    sql = "Select id, eventdate, eventtype, counter FROM eventlog";
>    sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);
>
>    rc = sqlite3_step(stmt);
>
> while(rc == SQLITE_ROW) {
>    id = sqlite3_column_int(stmt, 0 );
>    //cid = sqlite3_column_int(stmt, 1 );
>    evdate = (char*)sqlite3_column_text(stmt, 1 );
>    evtype = (char*)sqlite3_column_text(stmt, 2 );
>    evctr = sqlite3_column_int(stmt, 3 );
>
>    datetime = evdate;
>
>    datepart = datetime.Mid(0,10);
>    timepart = datetime.Mid(11,5);
>
>    std::cout << datepart << "\t" << timepart << std::endl;
>
>    newEvent.m_nEvent = the_event_ctr;
>    newEvent.m_strLastEventDate = datepart ;
>    newEvent.m_strEventTime = timepart;
>    newEvent.m_strEventType = evtype;
>    newEvent.m_nCount = evctr;
>    WriteEvent(newEvent, the_event_ctr);
>
>
>    rc = sqlite3_step(stmt);
>
>    // increment eventcounter
>    the_event_ctr++;
>
> } // while
>
> rc = sqlite3_reset(stmt);
>
> rc = sqlite3_finalize(stmt);
> rc = sqlite3_close(db);
>
> // sqlite3 reading ///
>
> }
>
> =
>
> What am I missing now ? There is a rc = sqlite3_reset(stmt);  but the rc =
> sqlite3_close(db);  still returns error_code 5
> The sqlite3_exec is now comment. Do I have to "reset " and finalize this
> part normally too ? How is this done ?


When you prepare "select * from eventlog" statement you do not re-use
sqlite3_stmt object, you create a new one losing pointer to the old
statement. So you have to call sqlite3_finalize(stmt) before calling
sqlite3_prepare() at this point. And you don't have to call
sqlite3_reset() if you'll call sqlite3_finlaize() right after that,
just use sqlite3_finalize().


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


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Richard Hipp
On Tue, Jun 26, 2012 at 11:50 AM, deltagam...@gmx.net
wrote:

> Am 26.06.2012 17:08, schrieb Pavel Ivanov:   // select count(*) from
> eventlog
> sqltotal = "Select count(*) from eventlog";
>rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
>rc = sqlite3_step(stmt);
>total_events = sqlite3_column_int(stmt, 0 );
>
>std::cout << total_events << std::endl;
>
>// select * from eventlog
>sql = "Select id, eventdate, eventtype, counter FROM eventlog";
>sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);
>

Error in the previous line.

You have created a prepared statement and stepped it, but you never
finalized it.  Then you overwrote the pointer to the original prepared
statement with a pointer to the new prepared statement, thus leaking the
original prepared statement.



>
>rc = sqlite3_step(stmt);
>
> while(rc == SQLITE_ROW) {
>id = sqlite3_column_int(stmt, 0 );
>//cid = sqlite3_column_int(stmt, 1 );
>evdate = (char*)sqlite3_column_text(**stmt, 1 );
>evtype = (char*)sqlite3_column_text(**stmt, 2 );
>evctr = sqlite3_column_int(stmt, 3 );
>
>datetime = evdate;
>
>datepart = datetime.Mid(0,10);
>timepart = datetime.Mid(11,5);
>
>std::cout << datepart << "\t" << timepart << std::endl;
>
>newEvent.m_nEvent = the_event_ctr;
>newEvent.m_strLastEventDate = datepart ;
>newEvent.m_strEventTime = timepart;
>newEvent.m_strEventType = evtype;
>newEvent.m_nCount = evctr;
>WriteEvent(newEvent, the_event_ctr);
>
>
>rc = sqlite3_step(stmt);
>
>// increment eventcounter
>the_event_ctr++;
>
> } // while
>
> rc = sqlite3_reset(stmt);
>
> rc = sqlite3_finalize(stmt);
> rc = sqlite3_close(db);
>
> // sqlite3 reading //**/
>
> }
>
> ==**==**
> =
>
> What am I missing now ? There is a rc = sqlite3_reset(stmt);  but the rc =
> sqlite3_close(db);  still returns error_code 5
> The sqlite3_exec is now comment. Do I have to "reset " and finalize this
> part normally too ? How is this done ?
>
>
> __**_
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread deltagam...@gmx.net

Am 26.06.2012 17:08, schrieb Pavel Ivanov:

You are leaking stmt statement (re-preparing without finaliznig) and
your call to sqlite3_close returns SQLITE_ERROR because of that, but
you don't even check that so you are leaking database connections as
well.

Pavel


On Tue, Jun 26, 2012 at 11:01 AM, deltagam...@gmx.net
 wrote:

Am 26.06.2012 16:49, schrieb Richard Hipp:


On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
wrote:


I have a c++ GUI application from where the db is read and the content is
displayed in a Clistbox.
Then I try to delete some rows from the sqlite3-db from the console.
After rereading from within the GUI the deleted rows are still there.

How is this possible ?


The GUI is holding a read transaction open.  Hence it sees a consistent
snapshot of the database from the moment in time when the transaction was
started.  Subsequent writes to the database are ignored by the GUI until
it
closes its current transaction and starts a new one.







void InitialReadEventsData()
{

// Remove all events from array
m_arrEvents.RemoveAll();

// write  events
Event newEvent;

// sqlite3 reading ///
int rc, id, total_events;
char *sql, *sqltotal;
char *evdate, *evtype;
int evctr;

int the_event_ctr = 0;

CString datetime;
CString datepart;
CString timepart;


sqlite3 *db;
sqlite3_stmt *stmt;

sqlite3_open("ah.db", &db);
/*
// check if table eventlog exists
char create_sql[] = "CREATE TABLE if not exists eventlog ("
"id INTEGER PRIMARY KEY,"
"eventdate DATETIME default current_timestamp,"
"eventtype TEXT,"
"counter INTEGER"
")";

rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);


*/

// select count(*) from eventlog
sqltotal = "Select count(*) from eventlog";
rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
rc = sqlite3_step(stmt);
total_events = sqlite3_column_int(stmt, 0 );

std::cout << total_events << std::endl;


// select * from eventlog
sql = "Select id, eventdate, eventtype, counter FROM eventlog";
sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);

rc = sqlite3_step(stmt);

while(rc == SQLITE_ROW) {
id = sqlite3_column_int(stmt, 0 );
//cid = sqlite3_column_int(stmt, 1 );
evdate = (char*)sqlite3_column_text(stmt, 1 );
evtype = (char*)sqlite3_column_text(stmt, 2 );
evctr = sqlite3_column_int(stmt, 3 );

datetime = evdate;

datepart = datetime.Mid(0,10);
timepart = datetime.Mid(11,5);

std::cout << datepart << "\t" << timepart << std::endl;

newEvent.m_nEvent = the_event_ctr;
newEvent.m_strLastEventDate = datepart ;
newEvent.m_strEventTime = timepart;
newEvent.m_strEventType = evtype;
newEvent.m_nCount = evctr;
WriteEvent(newEvent, the_event_ctr);

rc = sqlite3_step(stmt);

// increment eventcounter
the_event_ctr++;

} // while

rc = sqlite3_reset(stmt);

rc = sqlite3_finalize(stmt);
rc = sqlite3_close(db);

// sqlite3 reading ///

}

=

What am I missing now ? There is a rc = sqlite3_reset(stmt);  but the rc 
= sqlite3_close(db);  still returns error_code 5
The sqlite3_exec is now comment. Do I have to "reset " and finalize this 
part normally too ? How is this done ?


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


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Richard Hipp
On Tue, Jun 26, 2012 at 11:15 AM, Simon Slavin  wrote:

>
> On 26 Jun 2012, at 4:11pm, "Black, Michael (IS)" 
> wrote:
>
> > So...transaction is started at sqlite3_step and stays open until
> sqlite3_reset or sqlite3_finalize, right?
> >
> > sqlite3_close would do what if you didn't finalize?  Just a memory leak
> or worse?  Or would sqlite3_close return an error if there's an open
> transaction?
>
> 
>
> "Applications must finalize all prepared statements and close all BLOB
> handles associated with the sqlite3 object prior to attempting to close the
> object. If sqlite3_close() is called on a database connection that still
> has outstanding prepared statements or BLOB handles, then it returns
> SQLITE_BUSY."
>
>
> on the other hand ...
>
> "If sqlite3_close() is invoked while a transaction is open, the
> transaction is automatically rolled back."
>
> It is not an error to close the file while you're in the middle of a
> transaction.  It just means you didn't commit the transaction.
>

The second statement above refers to an explicit transaction created using
the BEGIN statement.  It does not follow that implied transactions created
by running queries are automatically cancelled when you do
sqlite3_close().  To cancel the implied transaction, you have to
sqlite3_reset() or sqlite3_finalize() the prepared statement that created
the transaction in the first place.


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



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Richard Hipp
On Tue, Jun 26, 2012 at 11:11 AM, Black, Michael (IS) <
michael.bla...@ngc.com> wrote:

> So...transaction is started at sqlite3_step and stays open until
> sqlite3_reset or sqlite3_finalize, right?
>
> sqlite3_close would do what if you didn't finalize?  Just a memory leak or
> worse?  Or would sqlite3_close return an error if there's an open
> transaction?
>

The first prepared statement is never reset or finalized.  It is merely
stepped once, and then the pointer to the prepared statement is overwritten
by a different pointer, thus leaking the perpared statement.

Because the prepared statement remains open, the sqlite3_close() call
fails.  The database connection remains open, with a half-run statement
holding open a read transaction.


>
>
>
>
>
> Michael D. Black
>
> Senior Scientist
>
> Advanced Analytics Directorate
>
> Advanced GEOINT Solutions Operating Unit
>
> Northrop Grumman Information Systems
>
> 
> From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org]
> on behalf of Richard Hipp [d...@sqlite.org]
> Sent: Tuesday, June 26, 2012 9:54 AM
> To: General Discussion of SQLite Database
> Subject: EXT :Re: [sqlite] access from 2 different programms to same
> sqlite3-db
>
> On Tue, Jun 26, 2012 at 10:51 AM, Black, Michael (IS) <
> michael.bla...@ngc.com> wrote:
>
> > Does that mean the "prepare" is wrapped inside a transaction?
> >
> >
> >
> > So you must finalize and re-prepare?
> >
>
> No.  It just means you need to run sqlite3_reset() on your prepared
> statements when you are finished with them, so that they will release the
> transaction they are holding.
>
>
>
>
> >
> >
> >
> > Michael D. Black
> >
> > Senior Scientist
> >
> > Advanced Analytics Directorate
> >
> > Advanced GEOINT Solutions Operating Unit
> >
> > Northrop Grumman Information Systems
> >
> > ________
> > From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org]
> > on behalf of Richard Hipp [d...@sqlite.org]
> > Sent: Tuesday, June 26, 2012 9:49 AM
> > To: General Discussion of SQLite Database
> > Subject: EXT :Re: [sqlite] access from 2 different programms to same
> > sqlite3-db
> >
> > On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
> > wrote:
> >
> > > I have a c++ GUI application from where the db is read and the content
> is
> > > displayed in a Clistbox.
> > > Then I try to delete some rows from the sqlite3-db from the console.
> > > After rereading from within the GUI the deleted rows are still there.
> > >
> > > How is this possible ?
> > >
> >
> > The GUI is holding a read transaction open.  Hence it sees a consistent
> > snapshot of the database from the moment in time when the transaction was
> > started.  Subsequent writes to the database are ignored by the GUI until
> it
> > closes its current transaction and starts a new one.
> >
> >
> > >
> > > __**_
> > > sqlite-users mailing list
> > > sqlite-users@sqlite.org
> > > http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<<
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users%3C>
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users<<
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users%3C>
> >
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users%3Chttp://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> > >>
> > >
> >
> >
> >
> > --
> > 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
> >
>
>
>
> --
> 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
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Richard Hipp
On Tue, Jun 26, 2012 at 11:08 AM, Pavel Ivanov  wrote:

> You are leaking stmt statement (re-preparing without finaliznig) and
> your call to sqlite3_close returns SQLITE_ERROR because of that, but
> you don't even check that so you are leaking database connections as
> well.
>

Good eye, Pavel!  Nicely done.


>
> Pavel
>
>
> On Tue, Jun 26, 2012 at 11:01 AM, deltagam...@gmx.net
>  wrote:
> > Am 26.06.2012 16:49, schrieb Richard Hipp:
> >
> >> On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
> >> wrote:
> >>
> >>> I have a c++ GUI application from where the db is read and the content
> is
> >>> displayed in a Clistbox.
> >>> Then I try to delete some rows from the sqlite3-db from the console.
> >>> After rereading from within the GUI the deleted rows are still there.
> >>>
> >>> How is this possible ?
> >>>
> >> The GUI is holding a read transaction open.  Hence it sees a consistent
> >> snapshot of the database from the moment in time when the transaction
> was
> >> started.  Subsequent writes to the database are ignored by the GUI until
> >> it
> >> closes its current transaction and starts a new one.
> >>
> >>
> >>
> >
> > How can I close the transaction , and later open a new one ?
> > BTW, transaction is still open although i use a sqlite3_close(db) ?
> >
> > Here is the code for reading from the db. By changing within the GUI from
> > tab viewevents to another tab and back again to tab viewevents, the db is
> > read again and should display all changes to the db which appeared during
> > that time.
> >
> > ==
> >
> > int ReadViewEventsFormDBData()
> > {
> >int nRetCode = ERROR_SUCCESS;
> >
> >// Remove all events from array
> >m_arrEvents.RemoveAll();
> >
> >// write  events
> >Event newEvent;
> >
> >int rc, id, total_events;
> >char *sql, *sqltotal;
> >char *evdate, *evtype;
> >int evctr;
> >
> >int the_event_ctr = 0;
> >
> >CString datetime;
> >CString datepart;
> >CString timepart;
> >
> >sqlite3 *db;
> >sqlite3_stmt *stmt;
> >
> >sqlite3_open("ah.db", &db);
> >
> >// check if table eventlog exists
> >char create_sql[] = "CREATE TABLE if not exists eventlog ("
> >"id INTEGER PRIMARY KEY,"
> >"eventdate DATETIME default current_timestamp,"
> >"eventtype TEXT,"
> >"counter INTEGER"
> >")";
> >
> >rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);
> >
> >// select count(*) from eventlog
> >sqltotal = "Select count(*) from eventlog";
> >rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
> >rc = sqlite3_step(stmt);
> >total_events = sqlite3_column_int(stmt, 0 );
> >
> >// select * from eventlog
> >sql = "Select id, eventdate, eventtype, counter FROM eventlog";
> >sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);
> >
> >
> >rc = sqlite3_step(stmt);
> >
> >while(rc == SQLITE_ROW) {
> >id = sqlite3_column_int(stmt, 0 );
> >//cid = sqlite3_column_int(stmt, 1 );
> >evdate = (char*)sqlite3_column_text(stmt, 1 );
> >evtype = (char*)sqlite3_column_text(stmt, 2 );
> >evctr = sqlite3_column_int(stmt, 3 );
> >
> >datetime = evdate;
> >
> >datepart = datetime.Mid(0,10);
> >timepart = datetime.Mid(11,5);
> >
> >std::cout << datepart << "\t" << timepart << std::endl;
> >
> >newEvent.m_nEvent = the_event_ctr;
> >newEvent.m_strLastEventDate = datepart ;
> >newEvent.m_strEventTime = timepart;
> >newEvent.m_strEventType = evtype;
> >newEvent.m_nCount = evctr;
> >
> >// add the new element to array
> >m_arrEvents.Add(newEvent);
> >
> >rc = sqlite3_step(stmt);
> >
> >// increment eventcounter
> >the_event_ctr++;
> >
> >} // while
> >
> >sqlite3_finalize(stmt);
> >sqlite3_close(db);
> >nRetCode = rc;
> >
> >return nRetCode;
> >
> > } // ReadViewEventsFormDBData
> >
> > =
> >
> >
> > ___
> > 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
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Simon Slavin

On 26 Jun 2012, at 4:11pm, "Black, Michael (IS)"  wrote:

> So...transaction is started at sqlite3_step and stays open until 
> sqlite3_reset or sqlite3_finalize, right?
> 
> sqlite3_close would do what if you didn't finalize?  Just a memory leak or 
> worse?  Or would sqlite3_close return an error if there's an open transaction?



"Applications must finalize all prepared statements and close all BLOB handles 
associated with the sqlite3 object prior to attempting to close the object. If 
sqlite3_close() is called on a database connection that still has outstanding 
prepared statements or BLOB handles, then it returns SQLITE_BUSY."


on the other hand ...

"If sqlite3_close() is invoked while a transaction is open, the transaction is 
automatically rolled back."

It is not an error to close the file while you're in the middle of a 
transaction.  It just means you didn't commit the transaction.

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


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Black, Michael (IS)
So...transaction is started at sqlite3_step and stays open until sqlite3_reset 
or sqlite3_finalize, right?

sqlite3_close would do what if you didn't finalize?  Just a memory leak or 
worse?  Or would sqlite3_close return an error if there's an open transaction?





Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems


From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Richard Hipp [d...@sqlite.org]
Sent: Tuesday, June 26, 2012 9:54 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] access from 2 different programms to same sqlite3-db

On Tue, Jun 26, 2012 at 10:51 AM, Black, Michael (IS) <
michael.bla...@ngc.com> wrote:

> Does that mean the "prepare" is wrapped inside a transaction?
>
>
>
> So you must finalize and re-prepare?
>

No.  It just means you need to run sqlite3_reset() on your prepared
statements when you are finished with them, so that they will release the
transaction they are holding.




>
>
>
> Michael D. Black
>
> Senior Scientist
>
> Advanced Analytics Directorate
>
> Advanced GEOINT Solutions Operating Unit
>
> Northrop Grumman Information Systems
>
> 
> From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org]
> on behalf of Richard Hipp [d...@sqlite.org]
> Sent: Tuesday, June 26, 2012 9:49 AM
> To: General Discussion of SQLite Database
> Subject: EXT :Re: [sqlite] access from 2 different programms to same
> sqlite3-db
>
> On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
> wrote:
>
> > I have a c++ GUI application from where the db is read and the content is
> > displayed in a Clistbox.
> > Then I try to delete some rows from the sqlite3-db from the console.
> > After rereading from within the GUI the deleted rows are still there.
> >
> > How is this possible ?
> >
>
> The GUI is holding a read transaction open.  Hence it sees a consistent
> snapshot of the database from the moment in time when the transaction was
> started.  Subsequent writes to the database are ignored by the GUI until it
> closes its current transaction and starts a new one.
>
>
> >
> > __**_
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<<http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users%3C>
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users<<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users%3C>
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users%3Chttp://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >>
> >
>
>
>
> --
> 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
>



--
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] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Pavel Ivanov
You are leaking stmt statement (re-preparing without finaliznig) and
your call to sqlite3_close returns SQLITE_ERROR because of that, but
you don't even check that so you are leaking database connections as
well.

Pavel


On Tue, Jun 26, 2012 at 11:01 AM, deltagam...@gmx.net
 wrote:
> Am 26.06.2012 16:49, schrieb Richard Hipp:
>
>> On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
>> wrote:
>>
>>> I have a c++ GUI application from where the db is read and the content is
>>> displayed in a Clistbox.
>>> Then I try to delete some rows from the sqlite3-db from the console.
>>> After rereading from within the GUI the deleted rows are still there.
>>>
>>> How is this possible ?
>>>
>> The GUI is holding a read transaction open.  Hence it sees a consistent
>> snapshot of the database from the moment in time when the transaction was
>> started.  Subsequent writes to the database are ignored by the GUI until
>> it
>> closes its current transaction and starts a new one.
>>
>>
>>
>
> How can I close the transaction , and later open a new one ?
> BTW, transaction is still open although i use a sqlite3_close(db) ?
>
> Here is the code for reading from the db. By changing within the GUI from
> tab viewevents to another tab and back again to tab viewevents, the db is
> read again and should display all changes to the db which appeared during
> that time.
>
> ==
>
> int ReadViewEventsFormDBData()
> {
>    int nRetCode = ERROR_SUCCESS;
>
>    // Remove all events from array
>    m_arrEvents.RemoveAll();
>
>    // write  events
>    Event newEvent;
>
>    int rc, id, total_events;
>    char *sql, *sqltotal;
>    char *evdate, *evtype;
>    int evctr;
>
>    int the_event_ctr = 0;
>
>    CString datetime;
>    CString datepart;
>    CString timepart;
>
>    sqlite3 *db;
>    sqlite3_stmt *stmt;
>
>    sqlite3_open("ah.db", &db);
>
>    // check if table eventlog exists
>    char create_sql[] = "CREATE TABLE if not exists eventlog ("
>        "id INTEGER PRIMARY KEY,"
>        "eventdate DATETIME default current_timestamp,"
>        "eventtype TEXT,"
>        "counter INTEGER"
>        ")";
>
>    rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);
>
>    // select count(*) from eventlog
>    sqltotal = "Select count(*) from eventlog";
>    rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
>    rc = sqlite3_step(stmt);
>    total_events = sqlite3_column_int(stmt, 0 );
>
>    // select * from eventlog
>    sql = "Select id, eventdate, eventtype, counter FROM eventlog";
>    sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);
>
>
>    rc = sqlite3_step(stmt);
>
>    while(rc == SQLITE_ROW) {
>        id = sqlite3_column_int(stmt, 0 );
>        //cid = sqlite3_column_int(stmt, 1 );
>        evdate = (char*)sqlite3_column_text(stmt, 1 );
>        evtype = (char*)sqlite3_column_text(stmt, 2 );
>        evctr = sqlite3_column_int(stmt, 3 );
>
>        datetime = evdate;
>
>        datepart = datetime.Mid(0,10);
>        timepart = datetime.Mid(11,5);
>
>        std::cout << datepart << "\t" << timepart << std::endl;
>
>        newEvent.m_nEvent = the_event_ctr;
>        newEvent.m_strLastEventDate = datepart ;
>        newEvent.m_strEventTime = timepart;
>        newEvent.m_strEventType = evtype;
>        newEvent.m_nCount = evctr;
>
>        // add the new element to array
>        m_arrEvents.Add(newEvent);
>
>        rc = sqlite3_step(stmt);
>
>        // increment eventcounter
>        the_event_ctr++;
>
>    } // while
>
>    sqlite3_finalize(stmt);
>    sqlite3_close(db);
>    nRetCode = rc;
>
>    return nRetCode;
>
> } // ReadViewEventsFormDBData
>
> =
>
>
> ___
> 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] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Richard Hipp
On Tue, Jun 26, 2012 at 11:01 AM, deltagam...@gmx.net
wrote:

> Am 26.06.2012 16:49, schrieb Richard Hipp:
>
>  On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
>> wrote:
>>
>>  I have a c++ GUI application from where the db is read and the content is
>>> displayed in a Clistbox.
>>> Then I try to delete some rows from the sqlite3-db from the console.
>>> After rereading from within the GUI the deleted rows are still there.
>>>
>>> How is this possible ?
>>>
>>>  The GUI is holding a read transaction open.  Hence it sees a consistent
>> snapshot of the database from the moment in time when the transaction was
>> started.  Subsequent writes to the database are ignored by the GUI until
>> it
>> closes its current transaction and starts a new one.
>>
>>
>>
>>
> How can I close the transaction , and later open a new one ?
> BTW, transaction is still open although i use a sqlite3_close(db) ?
>
> Here is the code for reading from the db. By changing within the GUI from
> tab viewevents to another tab and back again to tab viewevents, the db is
> read again and should display all changes to the db which appeared during
> that time.
>

Are you sure the db is being read again when you change tabs?  Have you set
a breakpoint to verify this?

And are you sure the database has changed?

And are you certain that your command-line and your GUI are using the same
database?


>
> ==**==**==
>
> int ReadViewEventsFormDBData()
> {
>int nRetCode = ERROR_SUCCESS;
>
>// Remove all events from array
>m_arrEvents.RemoveAll();
>
>// write  events
>Event newEvent;
>
>int rc, id, total_events;
>char *sql, *sqltotal;
>char *evdate, *evtype;
>int evctr;
>
>int the_event_ctr = 0;
>
>CString datetime;
>CString datepart;
>CString timepart;
>
>sqlite3 *db;
>sqlite3_stmt *stmt;
>
>sqlite3_open("ah.db", &db);
>
>// check if table eventlog exists
>char create_sql[] = "CREATE TABLE if not exists eventlog ("
>"id INTEGER PRIMARY KEY,"
>"eventdate DATETIME default current_timestamp,"
>"eventtype TEXT,"
>"counter INTEGER"
>")";
>
>rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);
>
>// select count(*) from eventlog
>sqltotal = "Select count(*) from eventlog";
>rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
>rc = sqlite3_step(stmt);
>total_events = sqlite3_column_int(stmt, 0 );
>
>// select * from eventlog
>sql = "Select id, eventdate, eventtype, counter FROM eventlog";
>sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);
>
>
>rc = sqlite3_step(stmt);
>
>while(rc == SQLITE_ROW) {
>id = sqlite3_column_int(stmt, 0 );
>//cid = sqlite3_column_int(stmt, 1 );
>evdate = (char*)sqlite3_column_text(**stmt, 1 );
>evtype = (char*)sqlite3_column_text(**stmt, 2 );
>evctr = sqlite3_column_int(stmt, 3 );
>
>datetime = evdate;
>
>datepart = datetime.Mid(0,10);
>timepart = datetime.Mid(11,5);
>
>std::cout << datepart << "\t" << timepart << std::endl;
>
>newEvent.m_nEvent = the_event_ctr;
>newEvent.m_strLastEventDate = datepart ;
>newEvent.m_strEventTime = timepart;
>newEvent.m_strEventType = evtype;
>newEvent.m_nCount = evctr;
>
>// add the new element to array
>m_arrEvents.Add(newEvent);
>
>rc = sqlite3_step(stmt);
>
>// increment eventcounter
>the_event_ctr++;
>
>} // while
>
>sqlite3_finalize(stmt);
>sqlite3_close(db);
>nRetCode = rc;
>
>return nRetCode;
>
> } // ReadViewEventsFormDBData
>
> ==**==**
> =
>
>
> __**_
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread deltagam...@gmx.net

Am 26.06.2012 16:49, schrieb Richard Hipp:

On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
wrote:


I have a c++ GUI application from where the db is read and the content is
displayed in a Clistbox.
Then I try to delete some rows from the sqlite3-db from the console.
After rereading from within the GUI the deleted rows are still there.

How is this possible ?


The GUI is holding a read transaction open.  Hence it sees a consistent
snapshot of the database from the moment in time when the transaction was
started.  Subsequent writes to the database are ignored by the GUI until it
closes its current transaction and starts a new one.





How can I close the transaction , and later open a new one ?
BTW, transaction is still open although i use a sqlite3_close(db) ?

Here is the code for reading from the db. By changing within the GUI 
from tab viewevents to another tab and back again to tab viewevents, the 
db is read again and should display all changes to the db which appeared 
during that time.


==

int ReadViewEventsFormDBData()
{
int nRetCode = ERROR_SUCCESS;

// Remove all events from array
m_arrEvents.RemoveAll();

// write  events
Event newEvent;

int rc, id, total_events;
char *sql, *sqltotal;
char *evdate, *evtype;
int evctr;

int the_event_ctr = 0;

CString datetime;
CString datepart;
CString timepart;

sqlite3 *db;
sqlite3_stmt *stmt;

sqlite3_open("ah.db", &db);

// check if table eventlog exists
char create_sql[] = "CREATE TABLE if not exists eventlog ("
"id INTEGER PRIMARY KEY,"
"eventdate DATETIME default current_timestamp,"
"eventtype TEXT,"
"counter INTEGER"
")";

rc = sqlite3_exec(db, create_sql, NULL, NULL, NULL);

// select count(*) from eventlog
sqltotal = "Select count(*) from eventlog";
rc = sqlite3_prepare(db, sqltotal, strlen(sqltotal), &stmt, NULL);
rc = sqlite3_step(stmt);
total_events = sqlite3_column_int(stmt, 0 );

// select * from eventlog
sql = "Select id, eventdate, eventtype, counter FROM eventlog";
sqlite3_prepare(db, sql, strlen(sql), &stmt, NULL);


rc = sqlite3_step(stmt);

while(rc == SQLITE_ROW) {
id = sqlite3_column_int(stmt, 0 );
//cid = sqlite3_column_int(stmt, 1 );
evdate = (char*)sqlite3_column_text(stmt, 1 );
evtype = (char*)sqlite3_column_text(stmt, 2 );
evctr = sqlite3_column_int(stmt, 3 );

datetime = evdate;

datepart = datetime.Mid(0,10);
timepart = datetime.Mid(11,5);

std::cout << datepart << "\t" << timepart << std::endl;

newEvent.m_nEvent = the_event_ctr;
newEvent.m_strLastEventDate = datepart ;
newEvent.m_strEventTime = timepart;
newEvent.m_strEventType = evtype;
newEvent.m_nCount = evctr;

// add the new element to array
m_arrEvents.Add(newEvent);

rc = sqlite3_step(stmt);

// increment eventcounter
the_event_ctr++;

} // while

sqlite3_finalize(stmt);
sqlite3_close(db);
nRetCode = rc;

return nRetCode;

} // ReadViewEventsFormDBData

=

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


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Richard Hipp
On Tue, Jun 26, 2012 at 10:51 AM, Black, Michael (IS) <
michael.bla...@ngc.com> wrote:

> Does that mean the "prepare" is wrapped inside a transaction?
>
>
>
> So you must finalize and re-prepare?
>

No.  It just means you need to run sqlite3_reset() on your prepared
statements when you are finished with them, so that they will release the
transaction they are holding.




>
>
>
> Michael D. Black
>
> Senior Scientist
>
> Advanced Analytics Directorate
>
> Advanced GEOINT Solutions Operating Unit
>
> Northrop Grumman Information Systems
>
> 
> From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org]
> on behalf of Richard Hipp [d...@sqlite.org]
> Sent: Tuesday, June 26, 2012 9:49 AM
> To: General Discussion of SQLite Database
> Subject: EXT :Re: [sqlite] access from 2 different programms to same
> sqlite3-db
>
> On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
> wrote:
>
> > I have a c++ GUI application from where the db is read and the content is
> > displayed in a Clistbox.
> > Then I try to delete some rows from the sqlite3-db from the console.
> > After rereading from within the GUI the deleted rows are still there.
> >
> > How is this possible ?
> >
>
> The GUI is holding a read transaction open.  Hence it sees a consistent
> snapshot of the database from the moment in time when the transaction was
> started.  Subsequent writes to the database are ignored by the GUI until it
> closes its current transaction and starts a new one.
>
>
> >
> > __**_
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users<
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users%3Chttp://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >>
> >
>
>
>
> --
> 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
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Black, Michael (IS)
Does that mean the "prepare" is wrapped inside a transaction?



So you must finalize and re-prepare?



Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems


From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Richard Hipp [d...@sqlite.org]
Sent: Tuesday, June 26, 2012 9:49 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] access from 2 different programms to same sqlite3-db

On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
wrote:

> I have a c++ GUI application from where the db is read and the content is
> displayed in a Clistbox.
> Then I try to delete some rows from the sqlite3-db from the console.
> After rereading from within the GUI the deleted rows are still there.
>
> How is this possible ?
>

The GUI is holding a read transaction open.  Hence it sees a consistent
snapshot of the database from the moment in time when the transaction was
started.  Subsequent writes to the database are ignored by the GUI until it
closes its current transaction and starts a new one.


>
> __**_
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users<http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users%3Chttp://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>>
>



--
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] access from 2 different programms to same sqlite3-db

2012-06-26 Thread Richard Hipp
On Tue, Jun 26, 2012 at 10:46 AM, deltagam...@gmx.net
wrote:

> I have a c++ GUI application from where the db is read and the content is
> displayed in a Clistbox.
> Then I try to delete some rows from the sqlite3-db from the console.
> After rereading from within the GUI the deleted rows are still there.
>
> How is this possible ?
>

The GUI is holding a read transaction open.  Hence it sees a consistent
snapshot of the database from the moment in time when the transaction was
started.  Subsequent writes to the database are ignored by the GUI until it
closes its current transaction and starts a new one.


>
> __**_
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users
>



-- 
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] access from 2 different programms to same sqlite3-db

2012-06-26 Thread deltagam...@gmx.net
I have a c++ GUI application from where the db is read and the content 
is displayed in a Clistbox.

Then I try to delete some rows from the sqlite3-db from the console.
After rereading from within the GUI the deleted rows are still there.

How is this possible ?

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