Unique_User <[EMAIL PROTECTED]>
wrote:
> 1. If I open database  A and B and get back handleA and handleB, can
> I call sqlite3* function for database A using handleB?

What do you mean, for database A? The connection handle determines which 
database you are talking to.

> 2. Could I close handleA after I got handleB and still use all open
> database files and tables or do I have to keep all database handles
> around?

"Open database file" and "open connection handle" are, basically, one 
and the same. By closing handleA, you close file A. Since handleB is 
still open, you can continue to work with database file B using that 
handle.

> 3. What's exactly the role of a database handle when working with
> several database files and ATTACHED databases?

It's simple, really. When you want to read or write a text file, you 
call fopen() and get back FILE* handle. Then you call fread() and 
fwrite() passing this file handle, so they know which file to read or 
write to. Finally, you close the file with fclose(). You can have 
multiple files open at the same time, each represented by its own FILE* 
handle (and, in principle, you can open the same file twice and get two 
handles to it).

Similarly, you open a SQLite database file with sqlite3_open, and get 
back a handle. You pass this handle to various SQLite functions, so they 
know which database to work on. When you are done with this database, 
you close the handle with sqlite3_close.

ATTACH statement allows one to open another database file under existing 
connection handle, so that you could run SQL queries that mention tables 
from both databases.

Igor Tandetnik



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

Reply via email to