Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql连接 #109

Open
Hang-shao opened this issue Aug 31, 2023 · 1 comment
Open

Mysql连接 #109

Hang-shao opened this issue Aug 31, 2023 · 1 comment

Comments

@Hang-shao
Copy link

Hang-shao commented Aug 31, 2023

Development has moved. Please open new issues at https://github.com/pypyodbc/pypyodbc/issues
请问想读取sql文件,connect连接的数据库类型是Mysql,应该怎么写哈?

pypyodbc.lowercase = False  # 是否将字段名转为小写
# conn = pypyodbc.connect(r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + filePath + ";Uid=;Pwd=;") 
conn = pypyodbc.connect('DSN=MYSQL' + filePath + ";Uid=;Pwd=;")
cursor = conn.cursor()
@braian87b
Copy link
Collaborator

您需要使用 Mysql 连接器,而不是 ODBC 连接器,您可以使用以下连接器:
https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html
这是一个更详细的教程,解释了前面的步骤和其他细节,如果您正在学习,这些细节将非常有用:
https://realpython.com/python-mysql/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants