[英]Python pyodbc write to Microsoft Azure SQL Database Error
I used to use Python pyodbc to write data to sql server Express, but Express reached 10B max disk, so I have to switch to Microsoft Azure SQL Database, I encountered below error我以前用Python pyodbc写数据到sql server Express,但是Express达到了10B max disk,所以我不得不切换到Microsoft Azure SQL Database,我遇到了下面的错误
ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Reference to database and/or server name in 'master.dbo.syscharsets' is not supported in this version of SQL Server. ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][ODBC SQL 服务器驱动程序][SQL Server]在此不支持对'master.dbo.syscharsets'中的数据库和/或服务器名称的引用版本 SQL 服务器。
the code I using我使用的代码
conn = pyodbc.connect('DRIVER={SQL Server};SERVER=192.111.111;DATABASE=MYDB;UID=' + keyring.get_password("local", "UID") + ';PWD=' + keyring.get_password("local", "PWD") + ';')
cursor = conn.cursor()
for index, row in df_add.iterrows():
cursor.execute("INSERT INTO mytable([ID],[CreateDate]) values(?,?)",row['ID'], row['CreateDate'])
conn.commit()
cursor.close()
conn.close()
thanks for the Microsoft team's answer, here's the step.感谢微软团队的回答,这是步骤。
1.download the new driver and install in your computer https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16 1.下载新的驱动程序并安装到您的计算机https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16
modify this part in my code, reference python code to connect from Microsoft在我的代码中修改这部分,参考python代码从微软连接
DRIVER={ODBC Driver 18 for SQL Server} DRIVER={SQL 服务器的 ODBC 驱动程序 18}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.