idfx

SQL parametric string

Aug 20th, 2021 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. def ps(s: str, t: str, f: tuple) -> str:
  2.     """Creating a parametric query substring"""
  3.    
  4.     r = s + "  " + t + " " + str(f).replace("'", "") + " VALUES (" + ("?, " * len(f))[0:-2] + ")"
  5.     return r
  6. s="INSERT INTO"
  7. t = "TableName"
  8. f = ('1', '2', '3')
  9. x = ps(s, t, f)
  10. print(x)
  11.  
Add Comment
Please, Sign In to add comment