Files
jogobot-red/mysql_red.py
GOLDERWEB – Jonathan Golder 71b9d3301d Initial structure of MySQL-Module
Use class to use an object for all MySQL stuff
2015-09-04 22:19:06 +02:00

24 lines
494 B
Python

try:
import oursql as mysqldb
except ImportError:
import MySQLdb as mysqldb
class MYSQL_RED:
def __init__( self, db_hostname, db_username, db_password, db_name ):
"""
Opens a connection to MySQL-DB
@returns mysql-stream MySQL Connection
"""
self.__connection = mysqldb.connect( host=db_hostname, user=db_username, passwd=db_password, db=db_name )
def close( self ):
"""
Before deleting instance, close connection to MySQL-DB
"""
self.__connection.close()