diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-02-13 02:42:02 -0800 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-02-13 02:42:02 -0800 |
| commit | fd640b170a64584fd9c295be53c91972ff9f9ec1 (patch) | |
| tree | c67e95b332e183bbf14065bba55dd77e86a71fbe /im/cgi-bin/db.py | |
| parent | 64f41d53728a966f10aef6d7ffbc00853d754300 (diff) | |
fixed some basics
Diffstat (limited to 'im/cgi-bin/db.py')
| -rwxr-xr-x | im/cgi-bin/db.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/im/cgi-bin/db.py b/im/cgi-bin/db.py new file mode 100755 index 0000000..4da7b83 --- /dev/null +++ b/im/cgi-bin/db.py @@ -0,0 +1,29 @@ +import MySQLdb +import time + +def now (): + return int(time.mktime(time.localtime())) +class db: + def __init__ (self): + self.conn = None + self.cursor = None + self.connect() + + def connect (self): + self.conn = MySQLdb.connect (host = "127.0.0.1", + user = "asdfus", + passwd = "gTYgT&M6q", + db = "asdfus") + 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() |
