Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite3_open - problems checking if a file is a sqlite3 database

Tags:

c++

c

sqlite

I'm working with sqlite3 for the first time, and cannot get it to properly check a file before it opens it. So far, sqlite always returns OK on any file.

Also, the file name is a variable returned from the GTK file chooser. It returns an absolute path, I'm guessing this is not a problem.

Thanks for any help.

This is a snippet of the code:

int rc;
char *filename;
sqlite3 *db;

filename = gtk_file_chooser_get_filename(etc.);

if(SQLITE_OK == rc = sqlite3_open(filename,&db))
{  etc. }
like image 511
Shawn Buckley Avatar asked Aug 30 '26 06:08

Shawn Buckley


1 Answers

sqlite3_open doesn't actually read the file until the first non-pragma statement is prepared.

sqlite3_open_v2 provides other options.

like image 116
Doug Currie Avatar answered Sep 02 '26 05:09

Doug Currie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!