Created
January 23, 2024 10:29
-
-
Save lol97/5861f4bbe17d157f8ca4ed86fd01a3a4 to your computer and use it in GitHub Desktop.
connect to database oracle from python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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