24 lines
494 B
Python
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()
|