Ignore:
Timestamp:
Dec 2, 2008 5:17:02 PM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
e087a7a
Parents:
b0b9499
Message:

mysql error handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/user_to_project.py

    rb0b9499 rff2d928  
    1010    sys.exit("Usage %s user project" % sys.argv[0])
    1111
    12 db = MySQLdb.connect(db='tbdb')
     12try:
     13    db = MySQLdb.connect(db='tbdb')
     14except Exception, e:
     15    if len(e.args) == 2:
     16        num, str = e.args
     17    else:
     18        str = unicode(e)
     19        num = -1
     20    sys.exit("Cannot connect: %s (%d)" % (str, num))
     21
    1322c = db.cursor()
    1423c.execute("select uid, uid_idx from users where uid=%s", (user,))
Note: See TracChangeset for help on using the changeset viewer.