Package buildbot :: Package db :: Module util
[frames] | no frames]

Source Code for Module buildbot.db.util

1 -def sql_insert(dbapi, table, columns):
2 """ 3 Make an SQL insert statement for the given table and columns, using the 4 appropriate paramstyle for the dbi. Note that this only supports positional 5 parameters. This will need to be reworked if Buildbot supports a backend with 6 a name-based paramstyle. 7 """ 8 9 if dbapi.paramstyle == 'qmark': 10 params = ",".join(("?",)*len(columns)) 11 elif dbapi.paramstyle == 'numeric': 12 params = ",".join(":%d" % d for d in range(1, len(columns)+1)) 13 elif dbapi.paramstyle == 'format': 14 params = ",".join(("%s",)*len(columns)) 15 else: 16 raise RuntimeError("unsupported paramstyle %s" % dbapi.paramstyle) 17 return "INSERT INTO %s (%s) VALUES (%s)" % (table, ", ".join(columns), params)
18