Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)
 
PREVIOUS NEXT
Tagged: #mysql #store #numpy #array
ADD COMMENT
Topic
Name
5+2 =