Answers for "mysql store numpy array"

0

mysql store numpy array

myNumpyArray = np.random.rand((3,3))

#convert to list, then to string, then store as VARCHAR(20000) in mysql
numpyString = str(myNumpyArray.tolist()) 
query = "insert into mytable(mycolumn) VAlUES ('"+numpyString+"')"
cursor.execute(query)

#Note: to retreive from mysql,you can convert to array using eval:
#myArray = eval(mycolumn)
Posted by: Guest on April-16-2021

Python Answers by Framework

Browse Popular Code Answers by Language