From d489eb062653a2726d4fbd42bfd34835dc770d4b Mon Sep 17 00:00:00 2001 From: Pepper Date: Thu, 26 Feb 2015 02:03:24 -0500 Subject: first --- db.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 db.py (limited to 'db.py') diff --git a/db.py b/db.py new file mode 100755 index 0000000..23ebbe4 --- /dev/null +++ b/db.py @@ -0,0 +1,31 @@ +import MySQLdb +USER = "asdfus" +PASSWORD = "urJJwLjdO9GPuOxk" +DATABASE = "asdfus" + +class db: + def __init__ (self): + self.conn = None + self.cursor = None + self.connect() + + def connect (self): + self.conn = MySQLdb.connect (host = "localhost", + user = USER, + passwd = PASSWORD, + db = DATABASE + ) + self.cursor = self.conn.cursor () + + def execute (self,sql,args=()): + try: + self.cursor.execute(sql,args) + except MySQLdb.Error, e: + print "Error %d: %s" % (e.args[0], e.args[1]) + # sys.exit (1) + self.connect() + self.cursor.execute(sql,args) + + def lastinsertid (self): + return DB.conn.insert_id() + -- cgit v1.2.3-70-g09d2