Skip to content

Instantly share code, notes, and snippets.

@lol97
Created January 23, 2024 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lol97/5861f4bbe17d157f8ca4ed86fd01a3a4 to your computer and use it in GitHub Desktop.
Save lol97/5861f4bbe17d157f8ca4ed86fd01a3a4 to your computer and use it in GitHub Desktop.
connect to database oracle from python
import cx_Oracle
try:
con = cx_Oracle.connect('demouser/demouser@localhost:1521/XEPDB1')
print(con.version)
cursor = con.cursor()
print(cursor)
except cx_Oracle.DatabaseError as e:
print("There is a problem with Oracle", e)
finally:
if cursor:
cursor.close()
if con:
con.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment