Re: DBAPI Paramstyle

From: Tim Roberts (timr_at_probo.com)
Date: 03/26/05


Date: Sat, 26 Mar 2005 00:54:09 -0800

Bob Parnes <rparnes@megalink.net> wrote:
>
>I have a mediocre talent at programming, which is why I chose python.
>For me it was a good choice. I note this so that I hope you understand why
>I say that I don't know what you are driving at. My understanding is that a
>paramstyle is more efficient than the traditional python approach for repeated
>use of a query. If so, then I do not see how the choice of a parameter is
>relevant. If it is more efficient only in a specific abstract case, then
>one would have to look for other reasons to use it in a practical application.

In theory, using a paramstyle allows the query to be sent to the SQL
database backend and compiled like a program. Then, successive uses of the
same query can be done by sending just the parameters, instead of sending
the entire query string to be parsed and compiled again and again. This is
commonly done with large production databases like SQL Server and Oracle.
For a complicated query, it can be a significant time savings.

However, to the best of my knowledge, none of the Python dbabi
implementations actually do that. So, the primary benefit of the
paramstyle method is that the database provider inserts whatever quoting is
required; you don't have to remember to put single quotes around the
arguments, and protect single quotes within the arguments by doubling them,
and so on.

-- 
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.


Relevant Pages

  • Re: Python good for data mining?
    ... was that I should first program my ideas in Python WITHOUT ... Pytables is my preferential python database because of ... it's excellent API to the acclaimed HDF5 database (used by very many ... It's been 10 years ago since I've done any programming in C ...
    (comp.lang.python)
  • Re: Programing Help Needed!
    ... Ed - if you are uncomfortable with programming, ... change it into an append query to append it to the second table. ... Access will create multiple records for each of the ... in an Access 2000 database. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Python good for data mining?
    ... was that I should first program my ideas in Python WITHOUT ... it's excellent API to the acclaimed HDF5 database (used by very many ... It's been 10 years ago since I've done any programming in C ... As for pytables: it is the most elegant programming interface for HDF ...
    (comp.lang.python)
  • Re: Seeking Python->mySQL OR module
    ... > database into highly pythonic objects. ... > create python classes which define the columns ... On MySQL the query is pretty darn trivial... ... SQL statements are required to get rows from the tables. ...
    (comp.lang.python)
  • Re: Confused by mysqli
    ... In 25 years of RDB programming I've never been able to do what you're trying to do efficiently unless I have an OO database - and MySQL isn't an OO database. ... Secondly, PHP doesn't use polymorphism in this way. ... fetch_assocon a query I prepared with bind variables, ...
    (comp.lang.php)