当前位置: 首页>>代码示例>>Python>>正文


Python pyodbc.ProgrammingError方法代码示例

本文整理汇总了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 
开发者ID:exasol,项目名称:script-languages,代码行数:13,代码来源:odbc.py

示例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() 
开发者ID:exasol,项目名称:python-exasol,代码行数:22,代码来源:exasol.py

示例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 
开发者ID:exasol,项目名称:python-exasol,代码行数:21,代码来源:udf_sdk.py

示例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 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:8,代码来源:connector.py

示例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]) 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:7,代码来源:connector.py

示例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 
开发者ID:exasol,项目名称:python-exasol,代码行数:7,代码来源:exasol.py

示例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() 
开发者ID:exasol,项目名称:python-exasol,代码行数:12,代码来源:exasol.py

示例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 
开发者ID:sabri-zaki,项目名称:EasY_HaCk,代码行数:8,代码来源:connector.py

示例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)) 
开发者ID:sabri-zaki,项目名称:EasY_HaCk,代码行数:7,代码来源:connector.py

示例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 
开发者ID:exasol,项目名称:python-exasol,代码行数:62,代码来源:exasol.py


注:本文中的pyodbc.ProgrammingError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。