Menu

Update Examples

Help
cmnorton
2010-03-05
2012-09-19
  • cmnorton

    cmnorton - 2010-03-05

    With MySQLDB is it possible to update with parameters?

    This is throwing a SQL error.

    upd_cs_sql_cmd = \

    """

    UPDATE synth_customer_synch

    (

    set EndpointId = %s, DeviceType = %s, ChannelNumber = %s, Status = %s,
    Longitutde = %s, Latitude = %s

    )

    WHERE AcctID = %s and MeterID = %s

    """

    in_row = main_in_cur.fetchone()

    while None != in_row:

    if in_row == None:

    continune

    while 1:

    amr_in_cur.execute(amr_sql_cmd, (in_row,))

    amr_row = amr_in_cur.fetchone()

    if None == amr_row:

    break

    print(amr_row)

    out_cur.execute(upd_cs_sql_cmd, (amr_row, amr_row, amr_row, amr_row, \

    amr_row, amr_row, in_row, in_row, ) )

     
  • cmnorton

    cmnorton - 2010-03-05

    I found a missing ';' and added it. Am still getting a SQL syntax error.

     
  • Andy Dustman

    Andy Dustman - 2010-03-05

    The proper SQL syntax is documented here: http://dev.mysql.com/doc/refman/5.0
    /en/update.html

    In short, you should remove some parentheses around your "set ..." clause.

     
  • Andy Dustman

    Andy Dustman - 2010-03-05

    Also, it is not necessary to add trailing semicolons (;) to SQL statements.
    You can, however, issue multiple statements in one query, separating them with
    semicolons. Be aware that this will return multiple result sets.

     
  • cmnorton

    cmnorton - 2010-03-05

    Thanks for all the info and doc pointer.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.