📜  mysql 存储 numpy 数组 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:08.648000             🧑  作者: Mango

代码示例1
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)