oracle / oracle/python-oracledb

Timezone missing from TIMESTAMP WITH TIME ZONE

Open
#274 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
451
Forks
119
PR merge metrics
No merged PRs in 30d

Description

  1. What versions are you using?
platform.platform: Linux-5.3.18-24.64-default-x86_64-with-glibc2.3.4
sys.maxsize > 2**32: True
platform.python_version: 3.6.13
oracledb.__version__: 1.4.2
server: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
  1. Is it an error or a hang or a crash?
    Error: CURRENT_TIMESTAMP is returned as a timezone-unaware datetime

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

When running SELECT CURRENT_TIMESTAMP FROM DUAL on DBeaver I get a TIMESTAMP WITH TIME ZONE
When running the script at the bottom of this report I get:

(datetime.datetime(2023, 12, 20, 18, 33, 28, 585660),)
Which is not timezone-aware

  1. Does your application call init_oracle_client()?

Yes it does

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

oracledb.init_oracle_client()

host = "hostname"
service_name = "servicename"
pw = "dbpass"
user = "username"

connection = oracledb.connect(
    user=user,
    sid=service_name,
    password=pw,
    host=host)

cursor = connection.cursor()
ts = cursor.execute("SELECT CURRENT_TIMESTAMP FROM DUAL").fetchall()
print("Current datetime: "+str(ts))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the runnable Python script and compare its SELECT CURRENT_TIMESTAMP result with the TIMESTAMP WITH TIME ZONE result reported from DBeaver, including the effect of init_oracle_client(). Trace the value returned by cursor.execute().fetchall(); done means the result preserves timezone information as a timezone-aware datetime.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.