Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It makes sense that it works because a statement like this:</p> <p><code>'some value goes here %s' % value</code></p> <p>Actually returns a string. It's probably a bit more logical to view it like this:</p> <p><code>result = ("%s limit 1" % sql) % table</code></p> <p>There's nothing expressly wrong with doing that, but chaining operators can lead to problems with figuring out where an error came from.</p> <p>So for instance, this works fine:</p> <pre><code>&gt;&gt;&gt; sql = 'a value of %s' &gt;&gt;&gt; x = 'some string %s with stuff' &gt;&gt;&gt; y = 'VALUE' &gt;&gt;&gt; x % sql % y 'some string a value of VALUE with stuff' </code></pre> <p>But if there was a formatting error in there (I realize this example is pathological, but it gets the point across):</p> <pre><code>&gt;&gt;&gt; sql = 'a value of %d' &gt;&gt;&gt; x = 'some string %d with stuff' &gt;&gt;&gt; y = 123 &gt;&gt;&gt; x % sql % y Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; TypeError: %d format: a number is required, not str </code></pre> <p>It's really not clear which <code>%d</code> is causing your error. For that reason, I would split it out and just use one <code>%</code> formatter per line if possible because then the traceback will be able to point you to exactly which line and which formatter had the issue.</p> <p>For the record, by doing it one formatter per line you'll also make life a lot easier for anyone else who has to read your code and try to figure out what's going on.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload