Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- import csv
- source_dir = "source_files/aws_bills/"
- source_file = "test_data.csv"
- source = source_dir + source_file
- def main():
- mydb = mysql.connector.connect(user='xxxx', password='xxxxxx',
- host='xxxxxx',
- database='aws_bill')
- cursor = mydb.cursor()
- with open(source) as csv_file:
- csv_reader = csv.reader(csv_file, delimiter=',')
- sql = "INSERT INTO billing_info (InvoiceId) VALUES (%d)"
- for row in csv_reader:
- print("Row type: ", type(row))
- print(row)
- #cursor.execute(sql, (row))
- #close the connection to the database.
- mydb.commit()
- cursor.close()
- print("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement