Skip to content

Instantly share code, notes, and snippets.

@Derrick-Sherrill
Created May 3, 2022 20:08
Show Gist options
  • Save Derrick-Sherrill/8266887036b3478010b29e0718beff9d to your computer and use it in GitHub Desktop.
Save Derrick-Sherrill/8266887036b3478010b29e0718beff9d to your computer and use it in GitHub Desktop.
insert statements using in video tutorial
# Pull in .secrets
import os
import mysql.connector
mydb = mysql.connector.connect(
host='nnsgluut5mye50or.cbetxkdyhwsb.us-east-1.rds.amazonaws.com',
user=os.environ.get('user'),
password=os.environ.get('password'),
port=3306,
database='jsfaxdu1coljgpvy'
)
# sql = "CREATE TABLE customers (name VARCHAR(255), address VARCHAR(255))"
mycursor = mydb.cursor()
# Begin insert Statements
sql = "INSERT INTO customers (name, address) VALUES (%s, %s)"
val = ("John", "Highway 21")
mycursor.execute(sql, val)
mydb.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment