Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pauldx/47f97ac7b4e8c1b236f1e9e8adfee83b to your computer and use it in GitHub Desktop.
Save pauldx/47f97ac7b4e8c1b236f1e9e8adfee83b to your computer and use it in GitHub Desktop.
Create connection sqlalchemy oracle
import cx_Oracle
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
oracle_connection_string = 'oracle+cx_oracle://{username}:{password}@{hostname}:{port}/{database}'
engine = create_engine(
oracle_connection_string.format(
username="username",
password="password",
hostname="host",
port="port",
database="service",
)
)
Session = sessionmaker(bind=engine)
session = Session()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment