Skip to content

Instantly share code, notes, and snippets.

@cjbj
Last active January 30, 2023 05:26
Show Gist options
  • Save cjbj/524c3e1cedd6ac3935817e182d734b97 to your computer and use it in GitHub Desktop.
Save cjbj/524c3e1cedd6ac3935817e182d734b97 to your computer and use it in GitHub Desktop.
import getpass
import os
import traceback
import oracledb
un = ''
cs = ''
pw = getpass.getpass(f'Enter password for {un}: ')
try:
connection = oracledb.connect(user=un, password=pw, dsn=cs)
with connection.cursor() as cursor:
sql = """select systimestamp from dual"""
for r, in cursor.execute(sql):
print(r)
except oracledb.Error as e:
error, = e.args
print(error.message)
traceback.print_tb(e.__traceback__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment