How do I connect as sysdba for oracle db using SQLALchemy


I am using sqlalchemy with flask and I want to connect to oracle DB as sysdba

 SQLALCHEMY_DATABASE_URI ='oracle+cx_oracle://sys:abc@DBNAME[mode=SYSDBA]'

This doesnt work and gives me a

 from flask import Flask  
 from flask.ext.sqlalchemy import SQLAlchemy

 app = Flask(__name__)
 db = SQLAlchemy(app)   
 from app import views,models

and I use this db object later. But I am not able to figure out how to write the

SQLALCHEMY_DATABASE_URI to login as sysdba

I also tried

CONN = cx_Oracle.connect('sys/abc', dsn='DBNAME', mode = cx_Oracle.SYSDBA)

But that also doesnt work. I get ORA-12154: TNS: could not resolve the connect identifier specified” .. also If I remove mode=SYSDBA I get ORA-28009 connection as SYS should be as SYSDBA

3/24/2014 9:10:35 PM

Your dsn parameter is wrong. You must also separate the user and password parameters. Try this (it's working for me):

dsn_tns = cx_Oracle.makedsn('host', port, 'sid')
CONN = cx_Oracle.connect('sys', 'abc', dsn_tns, mode=cx_Oracle.SYSDBA)

For more info see cx_Oracle.connect constructor.

7/26/2016 5:51:05 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow