On 14 Apr 2017, at 3:44pm, Igor Korot <[email protected]> wrote:
> Thank you for clarifying.
> It means that the call to sqlite3_open() does not close previously
> opened database and I have to explicitly close it
> with sqlite3_close().
SQLite can open as many connections as you want. It hands you back a handle
for each one. If you want it to close one, you have to tell it which one you
want it to close.
So don’t do this:
sqlite3 *m_db;
int res = sqlite3_open( name1, &m_db );
//some database operations
res = sqlite3_open( name2, &m_db );
// stuff goes here
res = sqlite3_close(m_db);
do this:
sqlite3 *m_db;
int res = sqlite3_open( name1, &m_db );
//some database operations
res = sqlite3_close(m_db);
res = sqlite3_open( name2, &m_db );
// stuff goes here
res = sqlite3_close(m_db);
or this:
sqlite3 *m_db1;
sqlite3 *m_db2;
int res = sqlite3_open( name1, &m_db1 );
//some database operations
res = sqlite3_open( name2, &m_db2 );
// now they’re both open
// stuff goes here
res = sqlite3_close(m_db2);
// check result to see it closed okay
res = sqlite3_close(m_db1);
// check result to see it closed okay
Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users