Skip to content
Snippets Groups Projects
Commit 7df017a3 authored by Marco De Donno's avatar Marco De Donno
Browse files

Check for the fields type in the sql_insert_generate() function

parent 2106288b
No related branches found
No related tags found
No related merge requests found
...@@ -117,6 +117,12 @@ def pil2buffer( img, format ): ...@@ -117,6 +117,12 @@ def pil2buffer( img, format ):
return buff return buff
def sql_insert_generate( table, fields, returning = None ): def sql_insert_generate( table, fields, returning = None ):
if isinstance( fields, ( str ) ):
fields = [ fields ]
if not isinstance( fields, ( list, tuple, ) ):
raise Exception( "list or tuple needed as fields" )
f = ",".join( fields ) f = ",".join( fields )
place_holder = ",".join( [ "%s" ] * len( fields ) ) place_holder = ",".join( [ "%s" ] * len( fields ) )
sql = "INSERT INTO {} ({}) VALUES ({})".format( table, f, place_holder ) sql = "INSERT INTO {} ({}) VALUES ({})".format( table, f, place_holder )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment