当我想在Debian 9.1上运行我的python脚本时,我得到了这个错误消息。我使用的是MariaDB 10.1。
这里的问题是什么?我怎么才能修复它?
我的相关sql代码如下:
connection = MySQLdb.connect(host='localhost',
user='root',
passwd='1234',
db='database')
cursor = connection.cursor()
query = """ load data local infile 'MYOUTPUTLOCATION'
into table DEPARTURES
character set latin1
fields terminated by ';'
enclosed by '"'
lines terminated by '\r\n'
ignore 1 lines;
"""
cursor.execute(query)
connection.commit()
cursor.close()发布于 2021-09-06 06:54:33
正如注释中所提到的,python客户端需要本机库。通过在Debian9.*上安装libmariadbclient18来解决这个问题。
在Debian10 (Buster)上,这个包仍然只有libmariadbclient-dev版本。
发布于 2018-07-23 11:56:18
我报告了同样的错误,我发现这是因为我正在使用Python3,并且已经通过PIP3安装了mysqlconnect,以允许使用MySQLdb模块进行连接。这是失败的(Python3不支持MySQLdb,并且出于某种原因没有安装mysqlconnect )。
我通过pip3安装了PyMySQL,使用...
sudo pip3 install PyMySQL ..。然后在Python3代码中,我将模块从MySQLdb更改为pymysql (在一行中导入模块,然后使用它)。
https://stackoverflow.com/questions/46056826
复制相似问题