Closed amitdumka closed 2 months ago
after manual debuging oracledb file: connection.py location; class Connection(BaseConnection):
If print dns , param , kwargs i got this . out put
debug start
init function: dsn= (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=adb.eu-zurich-1.oraclecloud.com)(PORT=1521))(CONNECT_DATA=(SID=db001_high)))
init function: params= None
init function: kwargs= {'user': '
Traceback (most recent call last):
What my understanding say , first of all it is not reading file tnaname.ora and sqlnet.ora. if i remove this file output is same. second problem is setting PROTOCOL as TCP in place of TCPS. Connect_Data is different than what mention in tnsname.ora
kindly suggest what error i am making or it bud in code only.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.oracle',
'USER': '
}
}
it worked for me. i think it is problem either with oracledb or django auto db connection section. there should be option to use config_dir .
What did you have before that didn't work? The driver does indeed read sqlnet.ora and tnsnames.ora in thick mode if they are found in standard locations or if the environment variable TNS_ADMIN
is set. You can also call oracledb.init_oracle_client(config_dir="some_dir_of_choice")
to override the value of TNS_ADMIN
or to specific a value if the environment variable is not set. If you use thin mode you can specify the parameter config_dir
when creating a connection. This difference is due to the way that the Oracle Client libraries behave.
I used all these method you mention here. but for some reason it is not reading tnsname.ora. When i add this one of the entry from tnsname.ora in "NAME" field of Database Setting 'NAME': '(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.eu-zurich-1.oraclecloud.com))(connect_data=(service_name=db_actualname.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))', Like this. then i am able to connect. But if using this way , like just mentioning DNS name then it give lost contact.
I had tried Setting TNS_ADMIN, calling oracledb_init....(config_dir=...,, lib_dir=...)
In your DATABASES
dictionary have you tried removing the HOST
and PORT
values? It may be taking those and ignoring the NAME
value? And they are superfluous ayway. That would definitely cause the problem you are seeing, too!
Closing - no update
This my database config in setting.py
Code:
This Error dump Error:
Where i need to call init_oracle_client() to enable thick mode?
@NNE is enabled in my cloud database. I have set ORACLE_HOME, TNS_ADMIN and also change path in .ora file.
I am running same setting in normal python code . it gives perfect result. check that test code
Code:
Initialize the Oracle client library
Note: All I am facing problem in django app only. normal python , i am able to get data but in django i am getting TNS:lost contact. I tried in Local Windows 11 system and Oracle Cloud VM Ubuntu 22.04 Kindly suggest what can be done to over come this error.