Raw SQL Query " alter session set NLS_DATE_FORMAT='DD-MON-YYYY' " not updating in SQLAlchemy

Viewed 356

Here is an Oracle_Connect class defined in python having the connection initialization as given below.

from sqlalchemy import types, create_engine, inspect
from sqlalchemy.pool import NullPool

class OracleConnect():
    def __init__(self,username,password,db_name):
        self.conn = create_engine('oracle+cx_oracle://{}:{}@x601:1522/?service_name={}'.format(username,password,db_name), poolclass=NullPool)

An instance method defined in the class alters the session as shown below.

def set_dt_mask(self):
    self.conn.execute('''alter session set NLS_DATE_FORMAT=\'DD-MON-YYYY\'''')

When it's executed for the first time ever on my machine, it works by altering the datetime mask of the session. But let's suppose if we are to change the datetime mask it in future like

def set_dt_mask(self):
    self.conn.execute('''alter session set NLS_DATE_FORMAT=\'DD-MM-YYYY HH24:MI:SS\'''')

The statement is getting executed but, unfortunately not updating the datetime mask for the session. Its clings on the mask that was defined previously. Can something be done to resolve it?

0 Answers
Related