#Make sure you've INSTALLED PYMYSQL first! import pymysql #################### # Connect to the database you created # REPLACE THE FOLLOWING ITEMS AS STRING # YOU CAN COPY THE CONNECTION STRING AND FORMAT IT: hostname = "hostname given in Azure" password = "password given in Azure" username = "username given in Azure" dbname = "database name given in connection string in Azure" #################### db = pymysql.connect( host = hostname, passwd = password, user = username, db=dbname) cursor = db.cursor() create = """ CREATE TABLE BOO( Spooky_Costumes VARCHAR(30) NOT NULL, ID INT NOT NULL PRIMARY KEY, Price DECIMAL(5,2), Sales_Rating INT, Category VARCHAR(30)); """ cursor.execute( create ) cursor.execute('INSERT INTO BOO VALUES ("Bob the Builder", 735, 34.99, 5, "TV Show")') costumeName = "Psycho Dorothy" ID = "866" cursor.execute('INSERT INTO BOO (Spooky_Costumes,ID) VALUES (%s, %s)', (costumeName, ID)) cursor.execute('INSERT INTO BOO (Spooky_Costumes,ID, Price, Sales_Rating, Category) VALUES ("Borat", 423, 13.23, 5, "Movie")') sql = "SELECT * FROM BOO" rowCount=cursor.execute( sql ) print("This value should be 3: ",rowCount) print("That means that three rows were selected in from the table boo.") cursor.close() db.commit() #Makes sure the DB saves your changes! db.close()