'How to use Python to time update a MySQL dB from a CSV file?
I am building a php app where I am using phpMyAdmin for my SQL Database. I want a third party ftp save a CSV file periodically that has updated information. The Python 3.0 script will check for the updates and then update the SQL table. I tried creating the Python Script but ran into issues. Here is my latest code:
import pandas as pd
import pyodbc
import csv
import pymysql
#database connection
connection = pymysql.connect(host="localhost",user="my_user",passwd="my_pass",database="my_db")
cursor = connection.cursor()
sql = "SELECT ServiceStatus FROM carriercircuits WHERE CircuitServiceID = ?;"
df = pd.read_csv("circuits.csv")
df = pd.DataFrame({'CircuitServiceID= row[CircuitServiceID],ServiceStatus= row[ServiceStatus]'})
df.to_sql('carriercircuits', connection, if_exists='append', index=False)
for row in cursor.fetchall():
print (row)
conn.close()
The primary error code I received: DatabaseError: Execution failed on sql 'SELECT name FROM sqlite_master WHERE type='table' AND name=?;': not all arguments converted during string formatting
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
