I'm trying to create a Web application using flask and flask-sqlalchemy, i have the following code
    from flask.ext.sqlalchemy import  SQLAlchemy
    from flask import Flask
    app= Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI']=            'mysql+mysqldb://root:[email protected]/testdb'
    db = SQLAlchemy(app)
When i run db.create_all() from command line, i get unknown database 'testdb' error I'm working on ubuntu but the code above works on my windows machine.
I've tried adding the port number, removing the python connector but nothing works. below is the stack trace
 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 'testdb'") None None
                I would suggest that the database 'testdb' does not exist.
SQLAlchemy will not actually create the database for you. You have to connect to an existing database. It will then create all the tables.
Joe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With