[csw-maintainers] checkpkg: New feature: file collision detection

Maciej (Matchek) Blizinski maciej at opencsw.org
Tue Dec 14 11:11:38 CET 2010


No dia 13 de Dezembro de 2010 15:48, Peter FELECAN
<pfelecan at opencsw.org> escreveu:
>> An alternate approach would be to use sqlobject's SQL representation
>> generator - that would be much better.
>
> Probably. This is the issue with many abstraction mechanisms: when it
> comes to optimization it's a dicey game.

I looked at sqlobject's code - unfortunately, it's not possible,
because of how sqlobject is written.  They don't use SQL placeholders,
but instead do all the character escaping themselves and pass values
in text to the database module / cursor object.  This is curious,
because - SQL injection issues aside - having the module parse each
individual SQL query, including all data, probably gives worse
performance.  By how much exactly, I don't know - I tried to find
benchmarks on the web, but didn't so far.

I think we could have another shot at implementing placeholder-SQL
insertion, taking paramstyle into account.  It's not that easy,
unfortunately.  Paramstyle is defined on the module level, and we only
have the connection, which does not contain paramstyle information.
Finding out the module based on connection is in theory possible using
introspection[1], but the way to look it up depends on the
implementation of a specific database module, and we're back at the
original problem of writing database-independent code.

What sqlobject should be doing, is retaining paramstyle in its
connection objects the same way sqlalchemy does it[2].  But they don't
do that, unfortunately.

A quick-and-dirty approach would be: Since we don't know which
paramstyle to use, we try one of them, and if it fails, we catch the
exception and try again with another paramstyle.  If this fails too,
we bail out.  I would hate this kind of implementation, but having
this on one side, and impatient and angry Peter Felecan on the
other... I'd choose ugly code and happy Peter.

Any other ideas?

[1] http://stackoverflow.com/questions/1471304/how-do-i-determine-the-proper-paramstyle-when-all-i-have-is-a-connection-obje
[2] http://bitbucket.org/alberanid/imdbpy/src/25032948e09e/imdb/parser/sql/alchemyadapter.py#cl-495


More information about the maintainers mailing list