我在Python3.8中使用pymysql来允许Python连接到另一个MySQL服务器。我收到一个错误:
with pymysql.connect('127.0.0.1', user = '123', password = '123', port = server.local_bind_port) as connection:
AttributeError: __enter__
python:
from sshtunnel import SSHTunnelForwarder
import pymysql
我已经改变了下面的信任连接气流到mysql数据库。但气流雷达连接到默认的sqlite数据库。请参阅下面的配置,我试图连接到mysql。
1)config of airflow.cfg:
executor = LocalExecutor
sql_alchemy_conn = mysql+pymysql://root:12345678@localhost:3306/airflow
2) pip install PyMySQL (installed pyMysql package)
3)Installed mysql server in ubuntu machine where airflow
我在堆栈溢出和另一个编码示例站点中看到了本主题讨论的内容。但我找不到任何成熟的解决方案,有人修复这个错误吗?
错误信息:
ERROR:root:Can't connect to to MySQL server with error: (pymysql.err.InternalError) Packet sequence number wrong - got 1 expected 0
ERROR:root:Can't connect to to MySQL server with error: (pymysql.err.InternalError) Packet sequence
我正在尝试连接到Linux服务器上的数据库,使用PHP一切正常,使用:
$mysqli= new mysqli($_DBHOST, $_DBUSER, $_DBPASS, $_DB);
我也可以使用命令行连接:
mysql -u xxx -p
但是当我尝试使用pymysql连接Python时,我得到了以下错误:
pymysql.err.InternalError: (1130, "Host 'xxx' is not allowed to connect to
this MariaDB server")
Python代码:
import pymysql
conn
我对Django很陌生。配置MySQL引擎浪费了我整个下午的时间。我对数据库引擎和数据库驱动程序非常困惑。engine也是驱动程序吗?所有教程都说引擎应该是'django.db.backends.mysql',但是引擎如何决定使用哪个驱动程序连接MySQL呢?
每次它说'django.db.backends.mysql',遗憾的是,我不能安装MySQLDb和mysqlclient,但是PyMysql和官方的MySQL连接器2.1.3已经安装好了。如何将驱动程序设置为PyMysql或mysql连接器?
非常感谢!
OS: OS X Al Capitan
P
我正在使用google应用引擎
我的设置文件
import pymysql # noqa: 402
pymysql.install_as_MySQLdb()
if os.getenv('GAE_APPLICATION', None):
# Running on production App Engine, so connect to Google Cloud SQL using
# the unix socket at /cloudsql/<your-cloudsql-connection string>
DATABASES = {
我试图在这个完整的堆栈项目(Django/React)中为我的模型创建表。在运行python manage.py迁移命令之后,我希望看到:
X的迁移:
X\migrations\0001_initial_py
- Create model Departments
- Create model Employees
相反,我得到了以下错误:(9000,“不允许具有IP地址'X‘的客户端连接到此MySQL服务器。”
I have tried the command pip install pymysql
then edited the settings.py f