oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
307 stars 59 forks source link

Question , Is any way to set V$Session module, Action , Clientinfo before connection cursor created #343

Open koasi opened 4 weeks ago

koasi commented 4 weeks ago

Hey Guys I have a situsation, that we have to set V$session.client_identifier .client_identifier or V$session.PROGRAM when connection created.

I had study few thing

  1. in the oracledb sorce code V$session.PROGRAM is get from sys.executable, seems no possible to revise.

  2. Set connection.identifier , seems it only alter V$session.client_identifier after cursor created.

image

cjbj commented 3 weeks ago
koasi commented 3 weeks ago
  1. just wants set system key into Program, action , client_identifier . let database recognize if it's valid and it will not change during connection.
  2. I was faced some error , not resolved yet. anyway i can try.
  3. thanks for feedback, it's same as my consideration.
  4. I had tried driver_name, it's work success to set value when connection created, but due to following reason, i cannot use that

    a. limited length of driver_name columns. our sys key is very long. b. DBA seems disagree to use that due to unknow reason.

  5. "standalone connections but will have to investigate"good to hear that, I see the hope, can I expect a possible release date? about session_pool, I think it's bind with session should be reason able, also fit our purpose because we plan to use it to identify / verify application.
cjbj commented 3 weeks ago

Your best bet at the moment is to set the action & client_id after connection, and initiate a round trip to send the value to the DB. (Use a session callback if you are using a connection pool). Hopefully you are not connecting frequently, so the cost of the round trip will be amortized over the life of the connection. If you are creating standalone-connections frequently, then revise your design, perhaps to use a connection pool instead.

koasi commented 3 weeks ago

I also tried old cx_oracle by session_pool, when connection create, I also cannot set client id at 1st moment. can only set client_id after pool.acquire().