Sqlite3. Substitution of names in query.

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Sun Nov 1 16:34:25 EST 2009


In message <mailman.2418.1257062992.2807.python-list at python.org>, Carsten 
Haese wrote:

> Lawrence D'Oliveiro wrote:
>
>> In message <mailman.2397.1257034364.2807.python-list at python.org>,
>> Carsten Haese wrote:
>
>>> On what grounds are you asserting that it's not necessary to mix the
>>> two? Please elaborate your point.
>> 
>> On the grounds that Python has more general and powerful string
>> parameter- substitution mechanisms than anything built into any database
>> API.
> 
> That statement is fundamentally flawed. You are assuming that the
> preferred way of getting a value into a query is by substituting a
> literal into the query string. That is, in general, not true, because
> that would be horribly inefficient.

Says someone who hasn't realized where the real inefficiencies are. Remember 
what Tony Hoare told us: "premature optimization is the root of all evil". 
These are databases we're talking about. Real-world databases are large, and 
reside on disk, which is several orders of magnitude slower than RAM. And 
RAM is where string parameter substitutions take place. So a few hundred 
extra RAM accesses isn't going to make any significant difference to the 
speed of database queries.

> Finally, you're assuming that every value that can be supplied to a
> query actually HAS a literal form. That is not true. For example, in
> Informix databases, there are no literals for BYTE-type values.

Probably why I don't use Informix. What use is a binary data type if you 
can't insert and retrieve binary data values?




More information about the Python-list mailing list