summaryrefslogtreecommitdiff
path: root/test/dialect/oracle/_oracledb_mode.py
blob: a02a5389b2c2d068fa5380a650433532d6272b36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# do not import sqlalchemy testing feature in this file, since it's
# run directly, not passing through pytest
from sqlalchemy import create_engine


def _get_version(conn):
    # this is the suggested way of finding the mode, from
    # https://python-oracledb.readthedocs.io/en/latest/user_guide/tracing.html#vsessconinfo
    sql = (
        "SELECT UNIQUE CLIENT_DRIVER "
        "FROM V$SESSION_CONNECT_INFO "
        "WHERE SID = SYS_CONTEXT('USERENV', 'SID')"
    )
    return conn.exec_driver_sql(sql).scalar()


def run_thin_mode(url, queue, **kw):
    e = create_engine(url, **kw)
    with e.connect() as conn:
        res = _get_version(conn)
        queue.put((res, e.dialect.is_thin_mode(conn)))
    e.dispose()


def run_thick_mode(url, queue, **kw):
    e = create_engine(url, **kw)
    with e.connect() as conn:
        res = _get_version(conn)
        queue.put((res, e.dialect.is_thin_mode(conn)))
    e.dispose()