Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymssql
- conn = pymssql.connect(host='cypress.csil.sfu.ca',
- user='s_sttran', password='M3dEga6nR4yeJgNd', database='sttran354')
- print("Adding a song.")
- canInsert = False
- while not canInsert:
- mycursor = conn.cursor()
- try:
- songISRC = input("Enter the song's ISRC: ")
- songTitle = input("Enter the title of the song: ")
- songYear = input("Enter the year of the song: ")
- artistName = input("Enter the song's artist name: ")
- mycursor.execute("INSERT INTO Song VALUES (%s, %s, %d, %s)", (songISRC, songTitle, songYear, artistName))
- canInsert = True
- except Exception as e:
- print "Insertion failed. Please try again.", e
- mycursor.execute("SELECT s.isrc, s.title FROM Song s WHERE s.artistname = %s", artistName)
- row = mycursor.fetchone()
- while row:
- print "ISRC = %s, Title = %s" % (row[0], row[1])
- row = mycursor.fetchone()
- # mycursor.execute("SELECT m.firstname, m.lastname, m.birthdate FROM Song s, Plays p NATURAL JOIN Musician m WHERE p.artistname = s.artistname AND s.isrc = %s", songISRC)
- # row = mycursor.fetchone()
- # while row:
- # print "First Name = %s, Last Name = %s, Birth Date = %d" % (row[0], row[1], row[2])
- # row = mycursor.fetchone()
- mycursor.close()
- conn.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement