python access to TimesTen

后端 未结 5 1748
旧时难觅i
旧时难觅i 2021-01-14 20:17

I googled a lot to find any python module to access TimesTen (in memory database). I am writing a automated testing framework (more like for System Test and not Unit Test).

5条回答
  •  春和景丽
    2021-01-14 20:49

    To use Python with TimesTen (11.2 or 18.1), you should use cx_Oracle

    cx_Oracle works the same for both TimesTen and the Oracle RDBMS

    cx_Oracle uses ODPI-C which is a C library wrapper to OCI

    For both TimesTen and the Oracle RDBMS, cx_Oracle can either use the Easy connect method or tnsnames.ora in the connect string.

    The following cx_Oracle example uses tnsnames.ora [ie doug/doug@sampledb]

    # myscript.py
    
    from __future__ import print_function
    
    import cx_Oracle
    
    connection = cx_Oracle.connect("doug", "doug", "sampledb")
    cursor = connection.cursor()
    cursor.execute("insert into t values (42)")
    connection.commit()
    connection.close()
    

    The direct linked and client server tnsnames.ora entries for TimesTen 18.1.2.3 sampledb is:

    sampledb =(DESCRIPTION=(CONNECT_DATA = (SERVICE_NAME = sampledb)(SERVER = timesten_direct)))

    sampledbCS =(DESCRIPTION=(CONNECT_DATA = (SERVICE_NAME = sampledbCS)(SERVER = timesten_client)))

    As always, you need to source bin/ttenv.sh to configure the environment!

    On my Ubuntu 16.04 machine, my PATH and LD_LIBRARY_PATH were:

    echo $PATH /home/ubuntu/tt18123/bin:/home/ubuntu/tt18123/install/bin:/home/ubuntu/tt18123/install/ttoracle_home/instantclient_11_2:/home/ubuntu/tt18123/install/ttoracle_home/instantclient_11_2/sdk:/home/ubuntu/.cargo/bin:/home/ubuntu/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

    echo $LD_LIBRARY_PATH /home/ubuntu/tt18123/ttclasses/lib:/home/ubuntu/tt18123/install/lib:/home/ubuntu/tt18123/install/ttoracle_home/instantclient_11_2

    echo $TNS_ADMIN /home/ubuntu/tt18123/install/network/admin/samples

    Oracle TimesTen will officially support ODPI-C and cx_Oracle in TimesTen 18.1.3

    Please avoid using any ODBC based python libraries with TimesTen as cx_Oracle is what Oracle Development tests and develops against.

提交回复
热议问题