Initial structure of MySQL-Module

Use class to use an object for all MySQL stuff
This commit is contained in:
2015-09-04 22:19:06 +02:00
commit 71b9d3301d

23
mysql_red.py Normal file
View File

@@ -0,0 +1,23 @@
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()