sqlInsertStrFromList(table,
aList,
dbType=' postgres ' )
| source code
|
Take a list and make an insert string. This works with dictionaries
too. Here is a quick example:
>>> aList = [('one',1),('2','two'),('threepoint',3.)]
>>> sqlInsertStrFromList('myTable',aList,dbType='sqlite')
"insert into myTable (one,2,threepoint) values (1,'two',3.0);"
>>> sqlInsertStrFromList('myTable',aList)
"insert into mytable (one,2,threepoint) values (1,'two',3.0);"
- Parameters:
table (str) - Which table to insert into
aList - list of tubles pairs to insert - (name, value) @type
aList(list)
- Returns: str
- complete SQL insert command
|