Is it possible to use Mysql with SqlAlchemy and Flask if my mysql socket isn't in /tmp?

后端 未结 3 1798
遇见更好的自我
遇见更好的自我 2020-12-16 13:07

The location for mysql.sock on my system is /usr/local/mysql5/mysqld.sock

thrilllap-2:tmp reuven$ mysqld --print-defaults
mysqld would have          


        
3条回答
  •  感动是毒
    2020-12-16 14:10

    Yes! Sean was right

    app.config['SQLALCHEMY_DATABASE_URI'] = ''mysql://dayenu:secret.word@localhost/dayenu?unix_socket=/usr/local/mysql5/mysqld.sock
    db = SQLAlchemy(app)
    

    works fine! I think this parameter is used by pyodbc, which is what SQLAlchemy uses to talk to mysql, but I couldn't find this parameter anywhere in the pyodbc documentation.

提交回复
热议问题