Python connectivity with ATP DB is working fine on local machine using the below code
import oracledb
Define connection details
connection = oracledb.connect(
user="admin", # Replace with your Oracle ATP username
password="XXXX666", # Replace with your Oracle ATP password
dsn="tcps://adb.uk-london-1.oraclecloud.com:1522/gffad144248701c_mani.adb.oraclecloud.com", # DSN for Oracle ATP
config_dir="C:\oracle\Wallet_mani.zip", # Path to your wallet directory
wallet_location="C:\oracle\Wallet_mani", # Path to your wallet
wallet_password="XXXX666" # Optional: Replace with wallet password if required
)
Test the connection
try:
print("Connection successful!")
with connection.cursor() as cursor:
Example query
cursor.execute("SELECT SYSDATE||' Hum Tum Here ' FROM DUAL")
for row in cursor:
print("Database Date:", row[0])
except oracledb.DatabaseError as e:
print(f"An error occurred: {e}")
finally:
if 'connection' in locals() and connection:
connection.close()
Same code is not working at pythonanywhere.com
upload wallet file into Pythonanywhere.com home directory and update the code to fetch the directy which is unziped.