Search code examples
pythonoracle-databasepython-oracledb

Does python-oracledb use the sqlnet.ora file?


Will attributes in Oracle Database's application-tier sqlnet.ora file get used by Oracle's new python-oracledb driver? This optional Oracle Net Services file can configure various connection properties, including tracing, connection timeouts, keepalive times, and network encryption. For example what's the behavior if sqlnet.ora contains this?:

sqlnet.outbound_connect_timeout=5
sqlnet.expire_time=2

Solution

  • When you connect to Oracle Database in python-oracledb's default "thin" mode, any sqlnet.ora file will not be read. Instead many equivalent properties can be set as connection parameters, for example:

    connection = oracledb.connect(user=un, password=pw, dsn=cs,
                                  tcp_connect_timeout=10, expire_time=2)
    

    See the user documentation Creating a Standalone Connection.

    Conversely, when python-oracledb Thick mode is enabled by calling oracledb.init_oracle_client(), connecting in python-oracledb will read a sqlnet.ora file if it exists.

    See the user documentation on optional configuration files.

    You can alternatively (in both modes) set many of these options in the connect() dsn parameter as an 'Easy Connection Plus' connection string, see the technical brief Oracle Database Easy Connect Plus.