dbutils.nim 418 B

12345678910111213141516
  1. import db_common
  2. template dbFormatImpl*(formatstr: SqlQuery, dbQuote: proc (s: string): string, args: varargs[string]): string =
  3. var res = ""
  4. var a = 0
  5. for c in items(string(formatstr)):
  6. if c == '?':
  7. if a == args.len:
  8. dbError("""The number of "?" given exceeds the number of parameters present in the query.""")
  9. add(res, dbQuote(args[a]))
  10. inc(a)
  11. else:
  12. add(res, c)
  13. res