本文整理汇总了Python中pyodbc.ProgrammingError方法的典型用法代码示例。如果您正苦于以下问题:Python pyodbc.ProgrammingError方法的具体用法?Python pyodbc.ProgrammingError怎么用?Python pyodbc.ProgrammingError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyodbc
的用法示例。
在下文中一共展示了pyodbc.ProgrammingError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: query
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def query(self, qtext, *args):
if self.cursor is None:
raise ClientError('query() requires connect() first')
q = self.cursor.execute(qtext, *args)
try:
return q.fetchall()
except pyodbc.ProgrammingError as e:
if 'No results. Previous SQL was not a query.' in str(e):
return None
else:
raise
示例2: _startOutputService
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def _startOutputService(self):
"""Start service for EXASolution UDF scripts' output
After the service is running, the createScript function
produces additional code in scripts, which redirects the
stdout and stderr of a stript to this service.
The output of this service is the local stdout.
"""
if not self._connected:
raise pyodbc.ProgrammingError("Not connected")
self._stopOutputService()
self._outputService = ScriptOutputThread()
self._outputService.fileObject = self.outputFileObject
self._outputService.finished = False
self._outputService.serverAddress = self.clientAddress
self._outputService.init()
self.clientAddress = self._outputService.serverAddress
self._outputService.start()
示例3: setUp
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def setUp(self):
if sys.version_info[0:2] != expected_version:
self.skipTest('createScript expects Python %s' % '.'.join(map(str, expected_version)))
self.odbc_kwargs = {
#'DSN':'EXtest_start_external_service_get_dataAODBC_TEST',
'Driver': 'EXAODBC',
'EXAHOST': os.environ['ODBC_HOST'],
'EXAUID': os.environ['EXAUSER'],
'EXAPWD': os.environ['EXAPW']
}
if 'ODBC_LOG' in os.environ:
self.odbc_kwargs['LOGFILE'] = os.environ['ODBC_LOG']
with pyodbc.connect(**self.odbc_kwargs) as con:
try:
con.cursor().execute('CREATE SCHEMA foo')
except pyodbc.ProgrammingError:
# schema FOO exists
pass
示例4: fetchall
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def fetchall(self):
try:
return self.cursor.fetchall()
except pyodbc.ProgrammingError, msg:
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1])
return None
示例5: execute
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def execute(self, query):
try:
self.cursor.execute(query)
except (pyodbc.OperationalError, pyodbc.ProgrammingError), msg:
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1])
示例6: __enter__
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def __enter__(self):
"""Allows to use E.connect in "with" statements"""
if not self._connected:
raise pyodbc.ProgrammingError("Not connected")
return self
示例7: close
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def close(self):
"""Closes the underlying pyodbc.Connection object and stops
any implicitly started output service."""
if not self._connected:
raise pyodbc.ProgrammingError("Not connected")
self._connected = False
try:
self.odbc.close()
finally:
self._stopOutputService()
示例8: fetchall
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def fetchall(self):
try:
return self.cursor.fetchall()
except pyodbc.ProgrammingError, msg:
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(msg))
return None
示例9: execute
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def execute(self, query):
try:
self.cursor.execute(query)
except (pyodbc.OperationalError, pyodbc.ProgrammingError), msg:
logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(msg))
示例10: readData
# 需要导入模块: import pyodbc [as 别名]
# 或者: from pyodbc import ProgrammingError [as 别名]
def readData(self, sqlCommand, readCallback=None, **kw):
"""Execute a DQL statement and returns the result
This is a optimized version of pyodbc.Connection.execute
function. ReadData returns per default a pandas data frame
or any other data, if a different readCallback was specified.
readCallback
A function, which is called with the file object contained
the query result as CSV and all keyword arguments given to
readData. The returned data will be returned from
readData function.
"""
if not self._connected:
raise pyodbc.ProgrammingError("Not connected")
if readCallback is None:
if self.csvIsDefault:
readCallback = csvReadCallback
else:
readCallback = pandasReadCallback
odbc = self.odbc
self.odbc = None # during command execution is odbc not usable
try:
srv = TunneledTCPServer(self.serverAddress, HTTPIOHandler)
srv.pipeInFd, srv.pipeOutFd = os.pipe()
srv.outputMode = True
srv.error, srv.pipeIn, srv.pipeOut = None, os.fdopen(srv.pipeInFd), os.fdopen(srv.pipeOutFd, 'w')
s = HTTPIOServerThread()
s.srv = srv
srv.serverThread = s
q = HTTPExportQueryThread()
q.srv = srv
srv.queryThread = q
q.sqlCommand = sqlCommand
q.odbc = odbc
s.start()
q.start()
try:
try:
ret = readCallback(s.srv.pipeIn, **kw)
except Exception as err:
if srv.error is not None:
raise srv.error
raise err
finally:
srv.server_close()
try:
srv.pipeIn.close()
srv.pipeOut.close()
except:
pass
q.join()
s.join()
finally:
self.odbc = odbc
if srv.error is not None:
raise srv.error
return ret