sql - How to make %s in python a changing variable -


i writing program takes information csv file , writes sql database. getting different number of parameters write in different number of sql columns per file.

for example 1 person give me file parameters:

(color:green, length:100, width:200) 

which require statement like:

(insert xyz (color,length,width) values(%s,%s,%s), (color_variable, length_variable, width_variable) 

but person give me parameter thickness result in:

(insert xyz (thickness) values(%s), (thickness_variable) 

how make number of %s values have variable can change number of arguments in csv file

based in example assume sql database allows fields null.

in case, should generic statement inserting fields db, can insert ones provided user, , keep others null.

(insert xyz (color,length,width, thickness) values(%s,%s,%s, %s), (color_variable, length_variable, width_variable, thickness) 

then define null ones user provides.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -