Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

df to sql mysql

import pymysql
user = 'root'
passw = 'my-secret-pw-for-mysql-12ud'
host =  '172.17.0.2'
port = 3306
database = 'data_2'

#If you already have the database created, if databse is not created then create first then run the below script

conn = pymysql.connect(host=host,
                       port=port,
                       user=user, 
                       passwd=passw,  
                       db=database,
                       charset='utf8')

data.to_sql(name=database, con=conn, if_exists = 'replace', index=False, flavor = 'mysql')
Comment

PREVIOUS NEXT
Code Example
Python :: print with no newline 
:: how to download a project from pythonanywhere 
:: Python Tkinter Button Widget Syntax 
Python :: creating new column with dictionary 
Python ::  
::  
Python :: type de variable python 
Python :: python check if string contains 
::  
Python :: can only concatenate str (not "int") to str 
::  
:: how to replace a word in text file using python 
Python :: python file to list 
::  
:: django request user 
Python :: read .mat file in python 
::  
::  
::  
:: how to take space separated input in python 
Python :: remove white border matplotlib 
:: python convert input into lowercase 
:: letters to numbers python 
Python ::  
:: convert .py to .ipynb file 
Python :: update nested dictionary python 
Python :: how to calculate fibonacci numbers in python 
::  
Python :: modify a list with for loop and range function in python 
:: python 3.11 release date 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =