Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb
- class AdoptBranch:
- def __init__(self):
- self.connection = MySQLdb.connect(host='localhost',user='root', db='activeDB')
- self.cursor = self.connection.cursor()
- def __enter__(self):
- return self.cursor
- def __exit__(self, type, value, traceback):
- self.connection.commit()
- self.connection.close()
- @staticmethod
- def select_country():
- return 'select distinct countryName from FileOVPN'
- @staticmethod
- def select_state(country):
- return 'select stateProv FROM FileOVPN WHERE countryName = \'%s\'' % (country)
- """"""""""""""""""""""""""""""""""
- NEW FILE
- """"""""""""""""""""""""""""""""""
- def country():
- with AdoptBranch() as cur:
- cur.execute(AdoptBranch.select_country())
- return cur.fetchall()
- def state(country):
- with AdoptBranch() as cur:
- cur.execute(AdoptBranch.select_state(country))
- return cur.fetchall()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement