1

Topic: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

Greetings!
Prompt, please, as it is possible to be connected from cx_Oracle to PDB without usage tnsnames.ora and TWO_TASK?
cursor.execute And cursor.callproc similar do not support "alter session set container =".
The purpose - to launch from a python various  it is local on a host from a DB, thus to rely on a filling correctness tnsnames.ora it is impossible, therefore it is necessary without it. TWO_TASK too uses a name of a descriptor from tnsnames.ora
All thanks for answers!

2

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

cx_Oracle wrote:

Greetings!
Prompt, please, as it is possible to be connected from cx_Oracle to PDB without usage tnsnames.ora and TWO_TASK?
cursor.execute And cursor.callproc similar do not support "alter session set container =".
The purpose - to launch from a python various  it is local on a host from a DB, thus to rely on a filling correctness tnsnames.ora it is impossible, therefore it is necessary without it. TWO_TASK too uses a name of a descriptor from tnsnames.ora
All thanks for answers!

I am not on friendly terms with a python... And it cannot feed directly at connection connation string as ?

3

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

Q.Tarantino wrote:

without usage tnsnames.ora

cx_Oracle.makedsn

4

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

master_yoda wrote:

it is passed...
cx_Oracle.makedsn

It not to me as I understood, and ...

5

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

Forgot to specify that  it is required as / as sysdba
cx_Oracle.makedsn And easyconnect as I understand the login/password instructions demand, and to register and shine passwords sys very much it would not be desirable

6

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

cx_Oracle wrote:

Forgot to specify that  is required as / as sysdba

On the one hand, in a line of connection it is possible to transfer not only , but also all descriptor.
With another to be connected to PDB it is local (without the password), as far as I know, a little inconveniently - on SID it is impossible to be connected to the container.
With the third if to be connected locally to CDB, perhaps, alter session set container saves situation?

7

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

andrey_anonymous wrote:

it is passed...
On the one hand, in a line of connection it is possible to transfer not only , but also all descriptor.

Then it is necessary to be connected on login/password that less

andrey_anonymous wrote:

With another to be connected to PDB it is local (without the password), as far as I know, a little inconveniently - on SID it is impossible to be connected to the container.

Yes, I too did not find, except as through alter session set container or through hostname/pdb_service (easyconnect)

andrey_anonymous wrote:

With the third if to be connected locally to CDB, perhaps, alter session set container saves situation?

Probably I do something incorrectly, but meanwhile I receive or

cursor.execute ("alter session set container=CON1")
cx_Oracle. DatabaseError: ORA-24964: ALTER SESSION SET CONTAINER error

, Or 600

$ python/tmp/conn.py
Traceback (most recent call last):
File "/tmp/conn.py", line 17, in <module>
cursor.execute ("begin execute immediate ' alter session set container=CON1 '; end;")
cx_Oracle. DatabaseError: ORA-00600: internal error code, arguments: [kpoconReNegotiate-old client], [16388], [7], [], [], [], [], [], [], [], [], []

The code about the such

connection = cx_Oracle.connect (mode=cx_Oracle. SYSDBA)
cursor = connection.cursor ()
cursor.execute ("begin execute immediate ' alter session set container=CON1 '; end;")

8

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

Strongly!
Such errors does not happen
:
What version of the client?
Try  with new library libclntsh.so.12.1 or libclntsh.so.12.2
Apropos  authorizations:
1)  on one host with basis?
2) it is how much necessary SYSDBA?

9

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

cx_Oracle wrote:

it is passed...
Then it is necessary to be connected on login/password that less

If the main problem - to hide sys credentials - why not to hide them in wallet?
Regards
Maxim

10

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

cx_Oracle;
Locally:

11

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

cx_Oracle;
Does not approach?
conn stax@ (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (COMMUNITY = tcp.world) (PROTOCOL = TCP) (Host = xxx.xxx.com) (Port = 1521))) (CONNECT_DATA = (SID = ssss)))
.....
stax

12

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

Switching on the version  the client 12.2 (on a default in LB_LIBRARY_PATH it was picked up old 12.1) and an upgrade cx_Oracle helped
With such combination

(' cx_Oracle: ', ' 6.1 ')
(' Oracle Client: ', (12, 2, 0, 1, 0))

The code

cursor.execute (' alter session set container=CON1 ')

Fulfills!
All thanks for councils!

13

Re: How to be connected to PDB 12.2 it is local from python (cx_Oracle) WITHOUT tnsnames.ora?

cx_Oracle wrote:

the code

cursor.execute (' alter session set container=CON1 ')

Fulfills!

However do not confuse to be connected to PDB with set container:

SQL> connect / @sol12 as sysdba
Connected.
SQL> create user c##ommon identified by common container = all;
User created.
SQL> grant create session to c##ommon container = all;
Grant succeeded.
SQL> grant set container to c##ommon container = all;
Grant succeeded.

We create the trigger inhibitory login to given PDB

SQL> connect / @pdb1sol12 as sysdba
Connected.
SQL> create or replace
2 trigger c##ommon_logon_trigger
3 after logon
4 on c##ommon.schema
5 begin
6 raise_application_error (-20500, ' You are not allowed logging to this PDB. ');
7 end;
8 /
Trigger created.
SQL>

We are connected to CDB and  SET CONTAINER:

SQL> connect c##ommon@sol12
Enter password: ******
Connected.
SQL> alter session set container = pdb1sol12;
Session altered.
SQL>

As you see, AFTER LOGON  it was not caused. And now  to PDB:

SQL> connect c##ommon@pdb1sol12
Enter password: ******
ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-20500: You are not allowed logging to this PDB.
ORA-06512: at line 2
Warning: You are no longer connected to ORACLE.
SQL>

So-that SET CONTAINER! = LOGIN.
SY.