投稿

2021の投稿を表示しています

Spotfire write data to oracle by python importing ODP.NET (Oracle.DataAccess.dll)

# Write data to Oracle server ver. 19 import clr     clr.AddReferenceToFileAndPath(r"C:\app\Administrator\product\11.2.0\client_32\ODP.NET\bin\4\Oracle.DataAccess.dll") import System from System import * import Oracle.DataAccess from Oracle.DataAccess import * oradb="User Id=username; Password=userpassword; Data Source=(DESCRIPTION =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = MYDWH)))" conn= Client.OracleConnection(oradb) conn.Open() sql = "insert into  RYSYSM.COMMONTEMP (JOBNAME,COL01) VALUES('ODR.NET','test')" cmd = Client.OracleCommand(sql,conn) dr=cmd.ExecuteNonQuery() # you can also query by ExecuteReader() #sql = "select * from  RYSYSM.COMMONTEMP where JOBNAME='ODP.NET" #dr=cmd.ExecuteReader() #dr.Read() #print dr.GetString(0) #print dr.GetString(1) conn.Close() conn.Dispose() exit