How to use the pyodbc.OperationalError function in pyodbc

To help you get started, we’ve selected a few pyodbc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aioodbc / tests / test_cursor.py View on Github external
async def test_execute_on_closed_cursor(conn):
    cur = await conn.cursor()
    await cur.close()
    with pytest.raises(pyodbc.OperationalError):
        await cur.execute('SELECT 1;')
github cr0hn / golismero-legacy / tools / sqlmap / plugins / dbms / access / connector.py View on Github external
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])
        except pyodbc.Error, msg:
            raise SqlmapConnectionException(msg[1])

        self.connector.commit()
github opengisch / QgisModelBaker / QgisModelBaker / libqgsprojectgen / dbconnector / mssql_connector.py View on Github external
def __init__(self, uri, schema):
        DBConnector.__init__(self, uri, schema)

        try:
            self.conn = pyodbc.connect(uri)
        except (ProgrammingError, InterfaceError, pyodbc.Error, pyodbc.OperationalError) as e:
            raise DBConnectorError(str(e), e)

        self.schema = schema
        
        self._bMetadataTable = self._metadata_exists()
        self.iliCodeName = 'iliCode'
        self.tid = 'T_Id'
        self.dispName = 'dispName'
github sqlmapproject / sqlmap / plugins / dbms / access / connector.py View on Github external
def connect(self):
        if not IS_WIN:
            errMsg = "currently, direct connection to Microsoft Access database(s) "
            errMsg += "is restricted to Windows platforms"
            raise SqlmapUnsupportedFeatureException(errMsg)

        self.initConnection()
        self.checkFileDb()

        try:
            self.connector = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db)
        except (pyodbc.Error, pyodbc.OperationalError) as ex:
            raise SqlmapConnectionException(getSafeExString(ex))

        self.initCursor()
        self.printConnected()
github aio-libs / aioodbc / aioodbc / cursor.py View on Github external
async def _run_operation(self, func, *args, **kwargs):
        # execute func in thread pool of attached to cursor connection
        if not self._conn:
            raise pyodbc.OperationalError('Cursor is closed.')

        try:
            result = await self._conn._execute(func, *args, **kwargs)
            return result
        except pyodbc.Error as e:
            if self._conn and _is_conn_close_error(e):
                await self._conn.close()
            raise
github ponyorm / pony / pony / orm / dbproviders / mssqlserver.py View on Github external
def should_reconnect(provider, exc):
        return isinstance(exc, pyodbc.OperationalError)
github WhitewidowScanner / whitewidow / lib / modules / core / tools / thirdparty / sqlmap / plugins / dbms / access / connector.py View on Github external
def connect(self):
        if not IS_WIN:
            errMsg = "currently, direct connection to Microsoft Access database(s) "
            errMsg += "is restricted to Windows platforms"
            raise SqlmapUnsupportedFeatureException(errMsg)

        self.initConnection()
        self.checkFileDb()

        try:
            self.connector = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db)
        except (pyodbc.Error, pyodbc.OperationalError), msg:
            raise SqlmapConnectionException(msg[1])

        self.initCursor()
        self.printConnected()
github Arelle / Arelle / arelle / plugin / xbrlDB / SqlDb.py View on Github external
oracleConnect = cx_Oracle.connect
    oracleDatabaseError = cx_Oracle.DatabaseError
    oracleInterfaceError = cx_Oracle.InterfaceError
    oracleNCLOB = cx_Oracle.NCLOB
except ImportError:
    # also requires "Oracle Instant Client"
    hasOracle = False
    oracleConnect = noop
    oracleDatabaseError = oracleInterfaceError = NoopException
    oracleCLOB = None

try: 
    import pyodbc
    hasMSSql = True
    mssqlConnect = pyodbc.connect
    mssqlOperationalError = pyodbc.OperationalError
    mssqlProgrammingError = pyodbc.ProgrammingError
    mssqlInterfaceError = pyodbc.InterfaceError
    mssqlInternalError = pyodbc.InternalError
    mssqlDataError = pyodbc.DataError
    mssqlIntegrityError = pyodbc.IntegrityError
except ImportError:
    hasMSSql = False
    mssqlConnect = noop
    mssqlOperationalError = mssqlProgrammingError = mssqlInterfaceError = mssqlInternalError = \
        mssqlDataError = mssqlIntegrityError = NoopException

try: 
    import sqlite3
    hasSQLite = True
    sqliteConnect = sqlite3.connect
    sqliteParseDecltypes = sqlite3.PARSE_DECLTYPES