Scope: I am creating a data pipeline which requires me to SSH into a linux VM (all my code is there) and then send the data to a MariaDB Server
My python script extracts data from a CRM, saves it into a dataframe 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.")
I'm running:
python: 3.7.3
pyCharm IDE
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.