mysql store numpy array

Solutions on MaxInterview for mysql store numpy array by the best coders in the world

showing results for - "mysql store numpy array"
Milla
03 Mar 2020
1myNumpyArray = np.random.rand((3,3))
2
3#convert to list, then to string, then store as VARCHAR(20000) in mysql
4numpyString = str(myNumpyArray.tolist()) 
5query = "insert into mytable(mycolumn) VAlUES ('"+numpyString+"')"
6cursor.execute(query)
7
8#Note: to retreive from mysql,you can convert to array using eval:
9#myArray = eval(mycolumn)