Databases
General Info
Useful Snippets

5.0.2 Oracle Connection

Example:

# Create an Oracle connection
import cx_Oracle

# 2.0 Create a connection string and use it to create a DB engine
# 2.1 Create a string that you can plug your variables into
oracle_connection_string = ('oracle+cx_oracle://{username}:{password}@'+
                            cx_Oracle.makedsn('{hostname}', '{port}', service_name='{service_name}')

# 2.2 Format the connection string
formated_oracle_connection_string = oracle_connection_string.format(username     = "usename"
                                                    , password     = "oracle_password"
                                                    , hostname     = "hostname"
                                                    , port         = "port"  # 1571
                                                    , service_name = "Service_name")

# 2.3 Use the string to create a database connection
Oracle_DB_Engine = create_engine(formated_oracle_connection_string)