python postgres force varchar

165 Views Asked by At

I have a tuple like so ('35367911000001103', '0001') and im trying to use mogrify to insert both these values as a string but it keeps complaining that its out of range as an integer. The field is not an integer, its VARCHAR(255).

psycopg2.DataError: value "35367911000001103" is out of range for type integer

How can I force this value to be a string/varchar like its set out to be?

args_str = ','.join(cur.mogrify("(%s, %s)", x).decode('utf-8') for x in vpi_tuples)
cur.execute("INSERT INTO %s VALUES %s" % (table_name, args_str)) 
0

There are 0 best solutions below