SqlCat

class SqlCat(*parts)

Concatenates SQL fragments. Created via SQL.cat(*parts). Inherits from SqlObj.

Parameters:

parts – One or more items. SqlObj instances are rendered via their .sql() method. All other items are converted to strings and written as literal SQL (not parameterized).

SQL.cat('now()')
# now()

SQL.cat('price * ', SQL.value(1.1))
# sql:       price * %s
# args:      [1.1]
# mogrified: price * 1.1

SQL.cat('LIMIT ', 10)
# LIMIT 10  (10 is converted to the string '10', not parameterized)

SQL.cat('data ->> ', SQL.value('key'), ' = ', SQL.value('val'))
# sql:       data ->> %s = %s
# args:      ['key', 'val']
# mogrified: data ->> 'key' = 'val'