Oracle connection string with at sign @ in pasword

后端 未结 4 509
星月不相逢
星月不相逢 2021-01-13 19:43

I have a code that connect to oracle using connection string:

conn = cx_Oracle.connect(\'username/password@server:port/services\')

But the

相关标签:
4条回答
  • 2021-01-13 20:21

    I haven't tried cx_Oracle, but you might be able to connect by specifying the individual parameters -

    conn = cx_Oracle.connect(user='username', password='p@ssword', dsn='server:port/services')
    

    OR

    dsn_tns = cx_Oracle.makedsn('server', 'port', 'services')
    conn = cx_Oracle.connect(user='username', password='p@ssword', dsn=dsn_tns)
    
    0 讨论(0)
  • 2021-01-13 20:24

    FYI: This was a long-standing bug in Django. The first stable version containing the fix is v2.1

    0 讨论(0)
  • 2021-01-13 20:30

    You can use any of the following way based on Service Name or SID whatever you have.

    With SID:

    dsn_tns = cx_Oracle.makedsn('server', 'port', 'sid')
    conn = cx_Oracle.connect(user='username', password='p@ssword', dsn=dsn_tns)
    

    OR

    With Service Name:

    dsn_tns = cx_Oracle.makedsn('server', 'port', service_name='service_name')
    conn = cx_Oracle.connect(user='username', password='p@ssword', dsn=dsn_tns)
    
    0 讨论(0)
  • Does this work?

    conn = cx_Oracle.connect('username/"p@ssword"@server:port/services')
    
    0 讨论(0)
提交回复
热议问题