MySQL from python - dropping a database IF EXISTS

Ben Benjamin.Barker at gmail.com
Mon Dec 4 18:43:47 EST 2006


Ah well - I turned off warnings as a solution. Its a bit f a bodge, but
it works :-)


Ben wrote:

> Can someone explain why this might be happening:
>
> parser_beta.py:129: Warning: Can't drop database 'foobar'; database
> doesn't exist
>   self.cursor.execute("DROP DATABASE IF EXISTS "+name)
>
> But the whole point about the "IF EXISTS" bit is (I thought) that it
> will only drop it if it exists, if it doesn't do nothing and don't
> throw an error.
>
> I'm using MySQL 5.024 and python 2.4.3
>
> It still works, but the unneccesary error is annoying :-) Any ideas?
> 
> Cheers,
> 
> Ben




More information about the Python-list mailing list