Hi Tim,

select count(*) from sqlite_master;

will return 0 on a brand new db

Rgds,
Simon

2008/7/3 Tim Streater <[EMAIL PROTECTED]>:
> Hi,
>
> I have a PHP script that I run in Terminal under OS X, which opens an sqlite 
> db and works on it. Trouble is, if the db doesn't exist then the PHP library 
> silently creates an empty db with the given name. Given this, I need to 
> detect that the empty db has
> been created, delete it, and exit.
>
> As a work around I thought I might check that the newly opened db has no 
> tables, and clean up if so. My question is, what query can I make of the db 
> to determine that it has no tables? I couldn't find one (or perhaps I don't 
> know SQL well enough). If I
> run sqlite3 I can give it the .tables command - I suppose I could have a call 
> to this module from my script, but I'd prefer to avoid that. Alternatively is 
> then another approach?
>
> Thanks,
>
> -- Tim
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to