Connection to database
import datetimeimport pymysqlconn = pymysql.connect( host='localhost', user='XXXX', #password=, db='golf_db', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
Define variables for the table row
lastname="Doe"firstname="John"front9=8back9=8birthday=datetime.date(2025,1,31)
SQL statements to add row
with conn.cursor() as cursor: sql = "INSERT INTO `Golfers` (`Last_Name`, `First_Name`, `F_Handicap`, `B_Handicap`, `B_Date`) VALUES (%(lastname)s, %(firstname)s, %(front9)s, %(back9)s, %(birthday)s)" conn.commit()
Check to see if variables were properly defined
print(firstname, lastname, front9, back9, birthday)