A simple script that I think should work
import sqlite3 import pymysql
Connect to the SQLite database
sqlite_conn = sqlite3.connect('my_db.db') sqlite_cursor = sqlite_conn.cursor()
username="username" password="password" hostname="somewhere.mysql.pythonanywhere-services.com" databasename="overtherainbowandfaraway"
Connect to the MySQL database
mysql_conn = pymysql.connect(host=hostname, user=username, password=password, db=databasename) mysql_cursor = mysql_conn.cursor()
Get all rows from the SQLite table
sqlite_cursor.execute("SELECT * FROM baby_names_1976_2020") rows = sqlite_cursor.fetchall()
Insert each row into the MySQL table
for row in rows: mysql_cursor.execute("INSERT INTO baby_names VALUES (%s, %s, %s)", row) # Adjust the number of %s placeholders and the table name to match your data
Commit the changes and close the connections
mysql_conn.commit() sqlite_conn.close() mysql_conn.close()
Connection times out. Is it the ".mysql.pythonanywhere-services.com" bit that is wrong?