本文整理匯總了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