您好,有没有办法使用django-pyodbc与普及数据库?我尝试了不同的设置,但当我尝试检查数据库以从数据库创建模型时,它会显示此错误,但我可以使用python pyodbc在pervasive中创建查询。
`('42000','42000ODBC Client InterfacePervasiveInvalid SET statement. (0) (SQLExecDirectW)')请求方法: GET请求地址:
Django Version: 1.6.6 Exception Type: ProgrammingError Exception Value: ('42000', '[42000] [Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface]Invalid SET statement. (0) (SQLExecDirectW)') Exception Location: C:\Python27\lib\site-packages\django\_pyodbc\base.py in \_cursor, line 296 Python Executable: C:\Python27\python.exe Python Version: 2.7.8cursor.execute("SET DATEFORMAT Ymd; SET DATEFIRST %s" % self.datefirst)
pyodbc.ProgrammingError: ('42000', '[42000] [Pervasive][ODBC Client Interface][LNA][Pervasive] [ODBC Engine Interface]Invalid SET statement. (0) (SQLExecDirectW)')`这是我试图在数据库上运行检查数据库时出现的错误片段。
根据主要问题是在这个文件中,odbc第296行是base.py驱动程序上的set语句的一些问题,这是base.py上的一段代码,我试图对其进行注释,但之后又出现了另一个问题。
`cursor.execute("SET DATEFORMAT Ymd; SET DATEFIRST %s" % self.datefirst)
if self.ops.sql_server_ver < 2005:
self.creation.data_types['TextField'] = 'ntext'
self.features.can_return_id_from_insert = False
ms_sqlncli = re.compile('^((LIB)?SQLN?CLI|LIBMSODBCSQL)')
self.drv_name = self.connection.getinfo(Database.SQL_DRIVER_NAME).upper()
# http://msdn.microsoft.com/en-us/library/ms131686.aspx
if self.ops.sql_server_ver >= 2005 and ms_sqlncli.match(self.drv_name) and self.MARS_Connection:
# How to to activate it: Add 'MARS_Connection': True
# to the DATABASE_OPTIONS dictionary setting
self.features.can_use_chunked_reads = True` 发布于 2015-03-13 22:43:14
检查您的访问权限。错误消息指示语法错误,但根据mssql support site,错误代码42000是“语法错误或访问冲突”。
发布于 2017-11-25 04:11:58
尝试将单引号放在%s左右:
cursor.execute("SET DATEFORMAT Ymd; SET DATEFIRST '%s'" % self.datefirst)https://stackoverflow.com/questions/25558244
复制相似问题