python bottle sqlite edit code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jvandal
    New Member
    • Oct 2007
    • 4

    python bottle sqlite edit code

    ...def edit_member(no) :
    """
    Edit a gang member
    """
    print('edit member')
    if request.GET.get ('save', '').strip():
    edit = request.GET.tas k.strip()
    lastname = request.GET.get ('lastname', '').strip()
    firstname = request.GET.get ('firstname', '').strip()
    birthdate = request.GET.get ('birthdate', '').strip()
    deathdate = request.GET.get ('deathdate', '').strip()
    address = request.GET.get ('address', '').strip()
    city = request.GET.get ('city', '').strip()
    state = request.GET.get ('state', '').strip()
    zipcode = request.GET.get ('zip', '').strip()
    father = request.GET.get ('father', '').strip()
    mother = request.GET.get ('mother', '').strip()
    gangid = request.GET.get ('gangid', '').strip()
    status = request.GET.get ('status', '').strip()


    if status == 'open':
    status = 1
    else:
    status = 0

    conn = sqlite3.connect ('gang.db')
    c = conn.cursor()
    c.execute("UPDA TE gangmember set,\
    lastname = ?,\
    firstname = ?,\
    birthdate = ?,\
    deathdate = ?,\
    address = ?,\
    city = ?,\
    state = ?,\
    zipcode = ?,\
    father = ?,\
    mother = ?,\
    gangid = ?,\
    status = ?,\
    WHERE id LIKE ?", (lastname, firstname, birthdate, deathdate, address, city, state, zipcode, father, mother, gangid, status))
    conn.commit()
    return '<p>The item number %s was successfully updated</p>' % no

    else:
    conn = sqlite3.connect ('gang.db')
    c = conn.cursor()
    c.execute("SELE CT lastname, status FROM gangmember WHERE id LIKE ?", (str(no),))
    cur_data = c.fetchone()
    return template('edit_ member', old=cur_data, no=no)

    .....
    error.... File "gangmember.py" , line 117, in edit_member
    WHERE id LIKE ?", (lastname, firstname, birthdate, deathdate, address, city, state, zipcode, father, mother, gangid, status))
    OperationalErro r: near ",": syntax error
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    There should not be a comma here
    Code:
    (str(no),))
    Also, in the future, post your code between code tags (click on the code button above the box where you post). And paste the complete error message as we have no idea which comma the error is referring to.

    Comment

    Working...