Initial structure of MySQL-Module
Use class to use an object for all MySQL stuff
This commit is contained in:
23
mysql_red.py
Normal file
23
mysql_red.py
Normal 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()
|
||||
Reference in New Issue
Block a user