Reputation: 1284
Using python and SQLAlchemy sessions with an Oracle database, is it possible to get info about the corresponding Oracle v$session such as the sid or serial# from the session object? I could not find any mention of a sid or serial# in the session documentation here https://docs.sqlalchemy.org/en/13/faq/sessions.html
Upvotes: 0
Views: 510
Reputation: 9091
For its Oracle dialect, SQLAlchemy uses cx_oracle, which offers some limited access to v$session through the Connection object. I don't think you can view the sid or serial#, though?
However, you can look up the sid,serial# for the current session using SQL. Try this query from a similar question's answer
SELECT SID, SERIAL#
FROM V$SESSION
WHERE AUDSID = Sys_Context('USERENV', 'SESSIONID');
Upvotes: 2