Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb
- class DB:
- def __init__(self, db_config) :
- self.username = db_config["username"]
- self.password = db_config["password"]
- self.db = db_config["database"]
- self.host = '127.0.0.1'
- self.port = 3306
- if "host" in db_config:
- self.host = db_config["host"]
- if "port" in db_config:
- self.port = db_config["port"]
- def connect(self) :
- self.connection = MySQLdb.connect(
- host = self.host,
- user = self.username,
- passwd = self.password,
- db = self.db,
- port = self.port
- )
- self.cursor = self.connection.cursor()
- self.dict_cursor = self.connection.cursor(MySQLdb.cursors.DictCursor)
Advertisement
Add Comment
Please, Sign In to add comment