Advertisement
Guest User

Untitled

a guest
Nov 29th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import pymssql
  2. conn = pymssql.connect(host='cypress.csil.sfu.ca',
  3. user='s_sttran', password='M3dEga6nR4yeJgNd', database='sttran354')
  4. print("Adding a song.")
  5. canInsert = False
  6. while not canInsert:
  7. mycursor = conn.cursor()
  8. try:
  9. songISRC = input("Enter the song's ISRC: ")
  10. songTitle = input("Enter the title of the song: ")
  11. songYear = input("Enter the year of the song: ")
  12. artistName = input("Enter the song's artist name: ")
  13.  
  14. mycursor.execute("INSERT INTO Song VALUES (%s, %s, %d, %s)", (songISRC, songTitle, songYear, artistName))
  15. canInsert = True
  16. except Exception as e:
  17. print "Insertion failed. Please try again.", e
  18.  
  19. mycursor.execute("SELECT s.isrc, s.title FROM Song s WHERE s.artistname = %s", artistName)
  20. row = mycursor.fetchone()
  21. while row:
  22. print "ISRC = %s, Title = %s" % (row[0], row[1])
  23. row = mycursor.fetchone()
  24.  
  25. # 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)
  26. # row = mycursor.fetchone()
  27. # while row:
  28. # print "First Name = %s, Last Name = %s, Birth Date = %d" % (row[0], row[1], row[2])
  29. # row = mycursor.fetchone()
  30.  
  31. mycursor.close()
  32. conn.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement