Hi, I want to access data base with Python and want to transfer value retrieved by Python to Julia. Code is very common and available on internet. Pls check it is mentioned below:
import pyodbc
import DBConfig
import numpy as np
#string connection ="Data Source=KRISHNA\\SQLEXPRESS;Initial Catalog=msdb;Integrated Security=True"
def dbconn():
cnxn = pyodbc.connect(DBConfig.DBConnectString)
cursor = cnxn.cursor()
cursor.execute("SELECT * FROM BOM")
rows = cursor.fetchall()
bomid=np.empty(len(rows),dtype=object)
i=0
for row in rows:
bomid[i]=row.BOMID
i+=1
return bomid
Calling Python from Julia
module Test
export TestDB
BOMID=Dict()
julia_script_path="............/Julia/"
ENV["PYTHONPATH"]="............../Python/"
using PyCall
@pyimport pyodbc
@pyimport DBConnect
function TestDB()
BOMID=DBConnect.dbconn()
#for i=1:length(BOMID)
# println(string("BOM ID:",BOMID[i]))
#end
return BOMID
end
end
Code is working. But only problem is BOMID is taking the value
PyCall.PyObject[PyObject Decimal('1234'),PyObject Decimal('1235')]