MCPcopy Index your code
hub / github.com/webpy/webpy / query

Method query

web/db.py:209–232  ·  view source on GitHub ↗

Returns the query part of the sql query. >>> q = SQLQuery(["SELECT * FROM test WHERE name=", SQLParam('joe')]) >>> q.query() 'SELECT * FROM test WHERE name=%s' >>> q.query(paramstyle='qmark') 'SELECT * FROM test WHERE name=?'

(self, paramstyle=None)

Source from the content-addressed store, hash-verified

207 return isinstance(other, SQLQuery) and other.items == self.items
208
209 def query(self, paramstyle=None):
210 """
211 Returns the query part of the sql query.
212 >>> q = SQLQuery(["SELECT * FROM test WHERE name=", SQLParam('joe')])
213 >>> q.query()
214 'SELECT * FROM test WHERE name=%s'
215 >>> q.query(paramstyle='qmark')
216 'SELECT * FROM test WHERE name=?'
217 """
218 s = []
219 for x in self.items:
220 if isinstance(x, SQLParam):
221 x = x.get_marker(paramstyle)
222 s.append(safestr(x))
223 else:
224 x = safestr(x)
225 # automatically escape % characters in the query
226 # For backward compatibility, ignore escaping when the query
227 # looks already escaped
228 if paramstyle in ["format", "pyformat"]:
229 if "%" in x and "%%" not in x:
230 x = x.replace("%", "%%")
231 s.append(x)
232 return "".join(s)
233
234 def values(self):
235 """

Callers 2

__len__Method · 0.95
_strMethod · 0.95

Calls 4

safestrFunction · 0.85
get_markerMethod · 0.80
appendMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected