Advertisement
Guest User

Untitled

a guest
May 24th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1.  
  2. def init__database(self, command, user, password, host, port):
  3.     if command == 'CONNECT':
  4.         try:
  5.             self.db = MySQLdb.connect(host, port=port, user=user, passwd=password)
  6.         except MySQLdb.OperationalError:
  7.             ...
  8.                        
  9.     elif command == 'DISCONNECT':
  10.         # buat fungsi untuk reset form `user, password, host, & port` ke default.
  11.         return self.db.close()
  12.  
  13. def oke(self, Event=None):
  14.     self.user=self.E_user.get()
  15.     self.password=self.E_passw.get()
  16.    
  17.     try:
  18.         # disini self.db.cursor() sudah bisa dipake.
  19.         #self.db = MySQLdb.connect("localhost",port=3306, user=self.user, passwd=self.password)#, db="perbankan" )
  20.         self.cursor = self.db.cursor()
  21.         self.showdata.configure(state=NORMAL)
  22.         print 'sukses'
  23.     except MySQLdb.OperationalError:
  24.         ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement