如图所示,使用pymssql创建数据库连接,通过execute()执行SQL时,报错:
pymssql._mssql.MSSQLDatabaseException: (2714, b"There is already an object named '***_test111' in the database.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n")
原因是,之前运行过此程序,已经在数据库中创建了名为'***_test111'的表,
故需要加上一句,
drop table if exists ***_test111;
判断该表是否存在;若存在,需要先drop删除掉
注意:箭头所指的“;”分号别忘了,不然会报语法错误