参考文档:http://developer.teradata.com/tools/reference/teradata-python-module
#!/usr/bin/python
# encoding=utf-8
#连接Teradata
import teradataimport cx_Oracle
udaExec = teradata.UdaExec (appName="HelloWorld", version="1.0",logConsole=False)
session = udaExec.connect(method="odbc", system="192.168.1.175",username="dbc", password="dbc");
for row in session.execute("SEL * FROM DBC.TABLES"):
print(row)
print(row[0] + ": " + row[1])
print(row["tableName"])
print(row.name + ": " + row.val)
#连接orcle数据库
conn = cx_Oracle.connect('hr/hr@localhost/orcl')
cursor = conn.cursor ()
cursor.execute ("DROP TABLE TEST")
cursor.execute ("CREATE TABLE TEST(ID INT, COL1 VARCHAR(32), COL2 VARCHAR(32), COL3 VARCHAR(32))")
cursor.execute ("INSERT INTO TEST (ID, COL1, COL2, COL3)VALUES(1, 'a', 'b', 'c')")
cursor.execute ("INSERT INTO TEST (ID, COL1, COL2, COL3)VALUES(2, 'aa', 'bb', 'cc')")
cursor.execute ("INSERT INTO TEST (ID, COL1, COL2, COL3)VALUES(3, 'aaa', 'bbb', 'ccc')")
conn.commit()
cursor.close ()
conn.close ()