Advertisement
arturmnt

TESTEPYTHON

May 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/usr/bin/python3.4
  2.  
  3. import PyMySQL
  4.  
  5. # Open database connection
  6. db = PyMySQL.connect("localhost","root","SENHABANCO","BANCODADOS" )
  7.  
  8.  
  9. # prepare a cursor object using cursor() method
  10. cursor = db.cursor()
  11.  
  12. # execute SQL query using execute() method.
  13. cursor.execute("SELECT VERSION()")
  14.  
  15. # Fetch a single row using fetchone() method.
  16. data = cursor.fetchone()
  17.  
  18. print ("Database version : %s " % data)
  19.  
  20. # disconnect from server
  21. db.close()
  22.  
  23.  
  24. #####
  25. Erro
  26. Traceback (most recent call last):
  27. File "testeBanco.py", line 3, in <module>
  28. import PyMySQL
  29. ImportError: No module named 'PyMySQL'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement