From 71b9d3301d177f411272d7bfa9281c603d6329dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Fri, 4 Sep 2015 22:19:06 +0200 Subject: [PATCH] Initial structure of MySQL-Module Use class to use an object for all MySQL stuff --- mysql_red.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 mysql_red.py diff --git a/mysql_red.py b/mysql_red.py new file mode 100644 index 0000000..acc6161 --- /dev/null +++ b/mysql_red.py @@ -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()