Last month I have completed the majority of the Complete SQL boot camp. I wanted to learn the details about the SQL language to expand my ability to perform manual ETL functions in python. In my past posts I explained how I was able to run simple ETL scripts using mongodb running in a Linux AMI, in this build I used a simple SQL query to inject table values into a newly created table.
mycursor= cnx.cursor()
mycursor.execute("CREATE TABLE users (ID VARCHAR(255), Name VARCHAR(255), Department VARCHAR(255), Location VARCHAR(255), Pay VARCHAR(255))")
The table was created and values needed to be placed inside:
#Add Entries into SQL Table
sql = "INSERT INTO users (ID, Name, Department, Location, Pay) VALUES (%s, %s, %s, %s, %d)"
val = [
('0001', 'George Michaels', 'Maintenance', 'Warehouse 5', '50000', ),
]
mycursor.executemany(sql, val)
I thought about how to run my own SQL Queries/commands and began testing with the bootcamp sample database, I feel that this is going to be valuable knowledge in my future work with databases.