Warning: Can't create database 'TEST'; database exists

332 views
Skip to first unread message

Peter

unread,
Nov 23, 2009, 3:06:00 PM11/23/09
to sqlal...@googlegroups.com
Hi
I do:

engine = create_engine('mysql://root@localhost/tmp)
Session = sessionmaker()
Session.configure(bind=engine)
connection = engine.connect()
session = Session()

# suppose database TEST exists
connection.execute('CREATE DATABASE IF NOT EXISTS TEST')

Why does this gives a warning :

/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.6-py2.5.egg/sqlalchemy/engine/default.py:123:
Warning: Can't create database 'TEST'; database exists
cursor.execute(statement, parameters)

Thanks for your help
Peter

Conor

unread,
Nov 23, 2009, 5:43:42 PM11/23/09
to sqlal...@googlegroups.com
It looks like the MySQLdb cursor is emitting the warning, and AFAIK
there is no way to prevent MySQLdb from generating warnings. You can
tell Python to suppress this specific warning via:
import MySQLdb
import warnings
warnings.filterwarnings(
action="ignore",
category=MySQLdb.Warning,
message="Can't create database 'TEST'; database exists")

or suppress all MySQLdb warnings via:
import MySQLdb
import warnings
warnings.filterwarnings(
action="ignore",
category=MySQLdb.Warning)

-Conor

Reply all
Reply to author
Forward
0 new messages