Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- import mysql.connector
- config = {
- 'user': 'root',
- 'password': 'dipals',
- 'host': 'localhost',
- 'database': 'naseef_csv',
- 'raise_on_warnings': True
- }
- cnx = mysql.connector.connect(**config)
- cursor = cnx.cursor()
- add_tax_query = "INSERT INTO tax_data (c1, c2, c3, c4) VALUES(%s, %s, %s, %s)"
- with open('TAX_ROLL_05_16_19.txt') as csv_file:
- csv_reader = csv.reader(csv_file, delimiter='\t')
- line_count = 0
- for row in csv_reader:
- #print (",".join(row))
- #print (row[0])
- #print (row[1])
- #print (len(row))
- cursor.execute(add_tax_query, (row[0], row[1], row[2], row[3]))
- cnx.commit()
- cursor.close()
- cnx.close()
- print ('done')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement