Sep 15, 2021 8:14 AM
My python script extracts data from a CRM saves it into a data frame and then sends it to the DB.
when I run:
from sqlalchemy import create_engine f= open("db credentials,txt", "r") # parse credentials in txt to hide sensitive data sql_conn = f.read() conn = create_engine(sql_conn) df.to_sql(name='test_trx_1day', con=conn, if_exists='replace', index=False)
I get the following error:
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (3750, "Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset t his variable to avoid this message. Note that tables without a primary key can cause performance problems in row-ba sed replication, so please consult your DBA before changing this setting.")
pyCharm IDE - using top ide for web development
using pymysql as MySQL connector
When I run my code on my machine and the destination is my local MYSQL DB it works!
Note: I am not that familiar with Linux env so I am learning as I go along.
Sep 16, 2021 10:24 AM