i had question regarding usage of variables inside python function accesses postgresql server. example, following: def delete(): cur.execute( """delete potluck name = var_1;""" however, if wanted update function take in variables var_1, how so? for example, want function in form: def delete(var_1): cur.execute( """delete potluck name = %s;""", (var_1)) however, typing didn't work. in addition, how in case when: def delete(name, var_1): cur.execute( """delete potluck %s = %s;""", (name, var_1)) where don't want "name" have quotation marks when inserted string? any appreciated! to pass identifiers use psycopg2.extensions.asis from psycopg2.extensions import asis def update(table_name, var_1, var_2): cur.execute(""" update %s set %s = 'y' %s = 'john'; ...
Comments
Post a Comment