Completed

Insert records from Csv to Mysql by pyhton

Published on the October 13, 2019 in IT & Programming

About this project

Open

#!/Usr/bin/env python
# coding: utf-8

# In[ ]:
# filename: insert.py (for reference)

def  insertToMySQL(argument1, argument2, argument3);
import pymysql.cursors
import csv

mysqlconnection=pymysql.connect(host='192.0.0.0',port=1234,user='username',password='password',db='d _test',cursorclass=pymysql.cursors.DictCursor)
if mysqlconnection.open:
    print("OK")
    db_Info = mysqlconnection.get_server_info()
    print(db_Info)
    cursor = mysqlconnection.cursor()
   
with open('C:/test.csv') as csvfile:
    sp = csv.Dictreader(csvfile)
    for row in sp:
        << insert code here>>
        <<field type: datetime, varchar, double, float, text (with special character)>>
        print(sql)
        cursor.execute(sql)
#close the connection to the database.
Cursor.close()
mysqlconnection.close()
return “Done”

Category IT & Programming
Subcategory Other
Project size Small
Is this a project or a position? Project
I currently have I have specifications
Required availability As needed
API Integrations Other (Other APIs)

Delivery term: Not specified

Skills needed

Other projects posted by M. Y.