python访问TimesTen [英] python access to TimesTen

查看:334
本文介绍了python访问TimesTen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google上进行了大量搜索,以找到可访问TimesTen(在内存数据库中)的任何python模块. 我正在编写一个自动化测试框架(更像是系统测试而不是单元测试).有人知道这样的模块吗?最后的方法是自己写包装器,但这是我真的要避免的事情.

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). Is anyone aware of such module? The last resort is write the wrapper myself but this is something I really want to avoid.

推荐答案

要将Python与TimesTen(11.2或18.1)一起使用,应使用

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

cx_Oracle在TimesTen和Oracle RDBMS中的工作原理都相同

cx_Oracle works the same for both TimesTen and the Oracle RDBMS

cx_Oracle使用 ODPI-C ,它是

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

对于TimesTen和Oracle RDBMS,cx_Oracle都可以使用 tnsnames.ora 在连接字符串中.

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

以下cx_Oracle示例使用tnsnames.ora [ie doug/doug @ sampledb]

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()

TimesTen 18.1.2.3 sampledb的直接链接的和客户端服务器tnsnames.ora条目为:

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)))

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

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

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

一如既往,您需要获取bin/ttenv.sh的源文件以配置环境!

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

在我的Ubuntu 16.04计算机上,我的PATH和LD_LIBRARY_PATH为:

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

回显$ 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 $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

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

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

回显$ TNS_ADMIN /home/ubuntu/tt18123/install/network/admin/samples

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

Oracle TimesTen将在TimesTen 18.1.3中正式支持ODPI-C和cx_Oracle

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

请避免将任何基于ODBC的python python库与TimesTen一起使用,因为cx_Oracle是Oracle开发测试和开发的对象.

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

这篇关于python访问TimesTen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆