A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/oracle/python-oracledb/issues/499 below:

Fetching DATE/TIMESTAMP as DF converts to UTC TZ · Issue #499 · oracle/python-oracledb · GitHub

# I'm at America/Los_Angeles that is currently UTC-7
import oracledb
import pyarrow as pa

SQL = "select * from t_ts"
conn = oracledb.connect("...")
cursor = conn.cursor()
try:
    cursor.execute("drop table t_ts")
except Exception:
    pass
cursor.execute(
    "create table t_ts as select sysdate d1, trunc(sysdate) d2, systimestamp t1 from dual"
)

print(cursor.execute(SQL).fetchall())
# clean values as-is
# [
#   (datetime.datetime(2025, 5, 28, 11, 1, 11), 
#    datetime.datetime(2025, 5, 28, 0, 0),   
#    datetime.datetime(2025, 5, 28, 11, 1, 11, 875060)
# )]

odf = conn.fetch_df_all(SQL)
print(pa.Table.from_arrays(odf.column_arrays(), names=odf.column_names()))
# values below are TZ adjusted
# pyarrow.Table
# D1: timestamp[s]
# D2: timestamp[s]
# T1: timestamp[us]
# ----
# D1: [[2025-05-28 18:01:11]]
# D2: [[2025-05-28 07:00:00]]  
# T1: [[2025-05-28 18:01:11.875060]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4