I ran below code as a root user:
import sqlalchemy
engine = sqlalchemy.create_engine('mysql://user:password@server') # connect to
server
engine.execute("CREATE DATABASE mydb") #create db
engine.execute("USE mydb") # select new db
However the database couldn't be created. The error I got is:
File
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line
80, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py",
line 279, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in
Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in
__init__
super(Connection, self).__init__(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (OperationalError) (1049, "Unknown database
'mydb'") None None
Any idea?
Thank you very much!
LYH
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/VCaVuIagRW8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.