[DB-SIG] How to detect wether a database exist ?

Paul DuBois paul@dubois.ws
Fri, 6 Apr 2001 18:58:51 -0500


At 10:26 PM -0700 4/5/01, rho handsome wrote:
>Hello guys ... I am rather new at programming in
>Python and I hope to get some pointers from anyone out
>there who can help. I am using the MySQLdb bindings
>and there is one problem I face. I am writing an
>address book program. How do i check at when the
>program starts wether a certain database exist within
>the localhost and if it doesn't exist.. create it ?

SHOW DATABASES

lists all the databases.

SHOW DATABASES LIKE 'pattern'

shows databases with names that match the given SQL pattern.

So run one of those queries and inspect the output.