Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib default style 
Python :: Remove whitespace from str 
Python :: convert excel workbook to dataframe 
Python :: python print string and variable 
Python :: python qr decomposition 
Python :: black code formatter 
Python :: while python 
Python :: pyspark dataframe to dictionary 
Python :: get unique words from pandas dataframe 
Python :: for loop with index python 
Python :: __mul__ 
Python :: removing duplicates using json python 
Python :: remove trailing zeros python 
Python :: python internship 
Python :: plynomial regression implementation python 
Python :: change order of barh matplotlib 
Python :: how to concatenate in python 
Python :: check if a file exists in python 
Python :: decision tree python 
Python :: python keyboard input arrow keys 
Python :: Session in python requests 
Python :: why wont my python input accept string inputs 
Python :: return position of a unique value in python array 
Python :: how to make a grid in python 
Python :: how to sort dictionary in ascending order by sorted lambda function in python 
Python :: To Divide or Not To Divide codechef solution 
Python :: Django Abstract base classe 
Python :: Math Module degrees() Function in python 
Python :: slicing strings in python 
Python :: python choose function 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =