How to use pyodbc - 10 common examples

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 mkleehammer / pyodbc / tests2 / freetdstests.py View on Github external
def setUp(self):
        self.cnxn   = pyodbc.connect(self.connection_string)
        self.cursor = self.cnxn.cursor()

        for i in range(3):
            try:
                self.cursor.execute("drop table t%d" % i)
                self.cnxn.commit()
            except:
                pass

        for i in range(3):
            try:
                self.cursor.execute("drop procedure proc%d" % i)
                self.cnxn.commit()
            except:
                pass
github cyberark / secretless-broker / test / connector / tcp / mssql / client / odbc_client.py View on Github external
}
CONN_TEMPLATE_STR = ";".join(
    [
        "DRIVER={{ODBC Driver 17 for SQL Server}}",
        "SERVER={server}",
        "DATABASE={database}",
        "UID={username}",
        "PWD={password}",
        "applicationintent={application_intent}",
    ],
)
conn_string = CONN_TEMPLATE_STR.format(**CONN_INFO)
SQL_ATTR_CONNECTION_TIMEOUT = 113
login_timeout = 2
connection_timeout = 2
cnx = pyodbc.connect(conn_string,
                     timeout=login_timeout,
                     attrs_before={
                         SQL_ATTR_CONNECTION_TIMEOUT: connection_timeout,
                     })
cursor = cnx.cursor()

if args.query.strip() == "":
    exit()

cursor.execute(args.query)
for row in cursor:
    print(row)
github mkleehammer / pyodbc / tests3 / pgtests.py View on Github external
def test_version(self):
        self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.
github mkleehammer / pyodbc / tests2 / freetdstests.py View on Github external
def test_version(self):
        self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.
github mkleehammer / pyodbc / tests3 / accesstests.py View on Github external
def test_version(self):
        self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.
github mkleehammer / pyodbc / tests3 / sqlservertests.py View on Github external
def test_version(self):
        self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.
github mkleehammer / pyodbc / tests2 / pgtests.py View on Github external
def test_version(self):
        self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.
github mkleehammer / pyodbc / tests3 / sqlitetests.py View on Github external
def test_version(self):
        self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.
github mkleehammer / pyodbc / tests3 / mysqltests.py View on Github external
def test_version(self):
        self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.
github mkleehammer / pyodbc / tests3 / informixtests.py View on Github external
def test_version(self):
        self.assertEqual(3, len(pyodbc.version.split('.'))) # 1.3.1 etc.