I think there are some self-identifying bits at the start of a
valid SQLite file... you could open the file directly and check for
those.

   Or, if you're going to retrieve a list of table names from
sqlite_master when first opening the database, you could trap the
SQLITE_NOTADB when executing that query... that would do the trick as
well.

   -T


On Fri, Oct 17, 2008 at 12:48 PM, Antoine Caron <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
>
>
>   1st I'd like to say I'm pretty new to SQLite, about 1 week. I'm trying to
> handle correctly the DB opening and here's some question on this.
>
>
>
> #1 I'm validating the db.sqlite file exist. if it doesn't, it creates it,
> right ? so right after being created, is the sqlite_master table created
> right away and a valid table for me to fetch the list of tablename (which
> should be empty) ?
>
>
>
> #2 if my db.sqlite file exist, I'm doing a sqlite_open3 on it. I was hoping
> the error code returned to actually help me determine is the file is a valid
> DB but it don't seems to read at all from the file.  In fact, that's only
> when I 1st try to SELECT something from the file that I'm getting error_code
> 26
>
> #define SQLITE_NOTADB      26   /* File opened that is not a database file
> */
>
> As stated in  http://www.sqlite.org/capi3.html , the error code from 24-26
> present but that might just be new stuff since 3.0 I'm using 3.6  I'm giving
> an invalid DB file on purpose to simulate a corrupted DB.
>
> Is there a (Quick) way to check whether or not the opened file is a database
> way other than using sql_exec  ?
>
>
>
> _______________________________________________
> 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

Reply via email to