summaryrefslogtreecommitdiff
path: root/pb/lib/db.py
diff options
context:
space:
mode:
authorPepper <pepper@scannerjammer.com>2015-04-30 18:32:38 -0400
committerPepper <pepper@scannerjammer.com>2015-04-30 18:32:38 -0400
commit107bf3253c12b3a9f13dda26e13cf61b805faa55 (patch)
tree4bdd3dbfc4104ab534c3dad27eae25dea3eb7f60 /pb/lib/db.py
parentaa0f6b784b0c60c0af9465da61ad1c6b800d911b (diff)
master
Diffstat (limited to 'pb/lib/db.py')
-rwxr-xr-xpb/lib/db.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/pb/lib/db.py b/pb/lib/db.py
new file mode 100755
index 0000000..2570b4f
--- /dev/null
+++ b/pb/lib/db.py
@@ -0,0 +1,31 @@
+import MySQLdb
+USER = "asdfus"
+PASSWORD = "gTYgT&M6q"
+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()
+