> 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 <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 >> <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 >>>> <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 >>>>>> <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