[英]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,我想以sysdba的身份连接到Oracle DB
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__)
app.config.from_object('config')
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 SQLALCHEMY_DATABASE_URI以sysdba身份登录
I also tried 我也试过
CONN = cx_Oracle.connect('sys/abc', dsn='DBNAME', mode = cx_Oracle.SYSDBA)
SQLALCHEMY_DATABASE_URI = CONN
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
我得到ORA-12154:TNS:无法解析指定的连接标识符“ ..同样,如果我删除mode = SYSDBA,我得到ORA-28009连接,因为SYS应该像SYSDBA一样
Your dsn
parameter is wrong. 您的
dsn
参数错误。 You must also separate the user
and password
parameters. 您还必须分开
user
和password
参数。 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. 有关更多信息,请参见cx_Oracle.connect构造函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.