How to properly connect to sql server in python us

2019-05-19 15:45发布

问题:

When I type in the code:

connection = pypyodbc.connect(driver='{SQL Server}', server=ServerName, database=DatabaseName, uid=UserId, pwd=Password)

I get this error:

ProgrammingError: (u'42000', u"[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Reference to database and/or server name in 'master..sysdatabases' is not supported in this version of SQL Server.")

Does anyone know how to fix it?