Skip to content

Timestamp values differ between oracledb and cx_Oracleย #7

@doerwalter

Description

@doerwalter

Continued from #2

Timestamps fetched by oracledb have different values that those fetched by cx_Oracle. Using alter session set time_zone doesn't make a difference.

Python 3.10.4 (main, Apr 26 2022, 19:42:59) [Clang 13.1.6 (clang-1316.0.21.2)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.3.0 -- An enhanced Interactive Python. Type '?' for help.
๐Ÿ โ€” 1 โฏ odb = oracledb.connect("user/pwd@db")
๐Ÿ โ€” 2 โฏ cdb = cx_Oracle.connect("user/pwd@db")
๐Ÿ โ€” 3 โฏ oc = odb.cursor()
๐Ÿ โ€” 4 โฏ cc = cdb.cursor()
๐Ÿ โ€” 5 โฏ oc.execute("alter session set time_zone='Europe/Berlin'")
๐Ÿ โ€” 6 โฏ cc.execute("alter session set time_zone='Europe/Berlin'")
๐Ÿ โ€” 7 โฏ cc.execute("select start_date from dba_scheduler_jobs where job_name = 'LOG_CLEANUP_JOB'").fetchone()
๐Ÿ โ€” 7 โฎ (datetime.datetime(2019, 3, 26, 4, 33),)
๐Ÿ โ€” 8 โฏ oc.execute("select start_date from dba_scheduler_jobs where job_name = 'LOG_CLEANUP_JOB'").fetchone()
๐Ÿ โ€” 8 โฎ (datetime.datetime(2019, 3, 26, 2, 33),)
๐Ÿ โ€” 9 โฏ

The script

import sys, platform, oracledb

print(f"{platform.platform()=}")
print(f"{sys.maxsize > 2**32=}")
print(f"{platform.python_version()=}")
print(f"{oracledb.__version__=}")

gives the following output on my machine:

platform.platform()='macOS-12.4-x86_64-i386-64bit'
sys.maxsize > 2**32=True
platform.python_version()='3.10.4'
oracledb.__version__='1.0.0'

I'm using oracledb in thin mode.

The following Oracle related environment variables are set:

export ORACLE_HOME=~/oracle/instantclient_12_2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME
export NLS_LANG=GERMAN_GERMANY.AL32UTF8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions