Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systimestamp different between cx_Oracle and oracledb #140

Closed
BayerSe opened this issue Feb 10, 2023 · 3 comments
Closed

systimestamp different between cx_Oracle and oracledb #140

BayerSe opened this issue Feb 10, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@BayerSe
Copy link

BayerSe commented Feb 10, 2023

  1. What versions are you using?
Oracle 19c
platform.platform: Linux-5.4.0-137-generic-x86_64-with-glibc2.31
sys.maxsize > 2**32: True
platform.python_version: 3.10.9
oracledb.__version__: 1.2.2
  1. Is it an error or a hang or a crash?

Error

  1. What error(s) or behavior you are seeing?

The value of systimestamp is wrong, it is different to the value in the database and the value reported by cx_Oracle.

  1. Does your application call init_oracle_client()?

No.

  1. Include a runnable Python script that shows the problem.
import oracledb
import cx_Oracle

user ="..."
password = "..."
dsn = "...

with oracledb.connect(user=user, password=password, dsn=dsn) as connection:
    with connection.cursor() as cursor:
        sql = """select systimestamp, current_timestamp from dual"""
        for r in cursor.execute(sql):
            print(r)


with cx_Oracle.connect(user=user, password=password, dsn=dsn) as connection:
    with connection.cursor() as cursor:
        sql = """select systimestamp, current_timestamp from dual"""
        for r in cursor.execute(sql):
            print(r)

    import oracledb
    print("oracledb.__version__:", oracledb.__version__)
(datetime.datetime(2023, 2, 10, 12, 0, 22, 342835), datetime.datetime(2023, 2, 10, 11, 0, 22, 342837))
(datetime.datetime(2023, 2, 10, 12, 0, 22, 648352), datetime.datetime(2023, 2, 10, 12, 0, 22, 648355))

The value of "systimestamp" is off by 1 hour when using oracledb instead of cx_Oracle.

The values reported by the database are:

2023-02-10 12:05:12.906225 +01:00
2023-02-10 11:05:12.906228 +00:00
@BayerSe BayerSe added the bug Something isn't working label Feb 10, 2023
@BayerSe
Copy link
Author

BayerSe commented Feb 10, 2023

Oh I see. Thanks!

@BayerSe BayerSe closed this as completed Feb 10, 2023
@anthony-tuininga
Copy link
Member

If you want them to be the same, make sure to set the session time zone. The default session time zone for thin mode is UTC whereas for thick mode it is the client's time zone. You can request an enhancement to thin mode to do the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants