GoodManWEN/cx_Oracle_async

Support Rollback and Ping

sinys15 opened this issue · 8 comments

Could you please support
https://cx-oracle.readthedocs.io/en/latest/api_manual/connection.html
Connection.ping()
and
Connection.rollback()
methods.
This is must have.

Connection.module
Connection.action
Connection.client_identifier
Connection.clientinfo
Would be very nice too.

Thank you.

Added in the latest commit of dev branch , not sure if that's what result you expect. For the other four option , since I'm not famillar with oracle's unique feature , I'm not quite sure what

This write-only attribute sets the module column in the v$session table.

means in the doc , could you explain to me what's the use of those four options.

btw, session pool close feature updated also in the latest commit.

could you explain to me what's the use of those four options.

V$SESSION is DB view where you can see your connections. Sometimes when DB have a lot of connections it is not easy to understand which one is yours and what it is actually process in the current moment in your session. You can specify information about your program and action and additional information by this methods. It's usefull for you when you are triyng to understand what session doing. And Oracle can provide agregation information about spending time by modules in oracle statistics.

For example:
module: Payment service
action: Edit order
clientinfo: John Smith (code: xyz)

Alright , If I'm understanding correctly , v$session is a view (can be accessed by anyone) in which you can find infos of all activate connections , and you use options such as connection.module to set an unique identification of your current connection , but since these are all write-only property so that when you'd like to get access to those information you will use some command like SELECT sid , module , clientinfo FROM v$session ?

Here's a technical problem of python grammar implementing these write-only features. Since those property should connect to oracle db to be set , which means its a blocking IO operation , so that a await is suppose to be in the line of code:

async with pool.acquire() as conn:
    await conn.module = 'hello world'

Problem is python donot support these kind of grammar.

There is more information about it
https://cx-oracle.readthedocs.io/en/latest/user_guide/tracing_sql.html
Look at "Oracle Database End-to-End Tracing"

The attributes are sent to the database when the next round-trip to the database occurs, for example when the next SQL statement is executed.

I think this means that actually setting the values to the attributes doesn't do anything while the real query is not executed. It's looks like it is not blocking operation.

That's great ,thanks. And that's why I got no immediate response at server end so that I have to call a sleep query and then I could finally findout conn.module has changed.

New commit updated at dev branch , you can use the same way as cx_Oracle

async with pool.acquire() as conn:
    conn.module = 'test_module'
    conn.action = 'test_action'
    conn.client_identifier = 'test_identifier'
    conn.clientinfo = 'test_info'
    async with conn.cursor() as cursor:
        await cursor.execute(f"SELECT * FORM V$SESSION WHERE MODULE = 'test_module'")
        print(await cursor.fetchone())

If that's fine in your opinion I'll draft a new release to pypi.

Thank you. Ship it!

It would be nice to add also method
Connection.begin()

Thank you!