[pyar] Conectividad a Base de Datos

Mariano Reingart reingart en gmail.com
Mie Jun 8 10:42:50 ART 2011


On Wed, Jun 8, 2011 at 3:18 AM, Will Santana <wisahe en gmail.com> wrote:
> El 06/06/2011 03:51 p.m., Juan Manuel Santos escribió:
>
>> Si lo que tenés que hacer es simple (no tenés joins muy rebuscados por
>> ejemplo), antes que Elixir te recomendaría SQLObject, es muy intuitivo.
>>
>> Saludos
>> Juan Manuel
>
> Lo revisé e hice el tutorial... Me encantó, sólo que tiene sus [1]detalles:
>
> ***Extracto sacado de la web.
>
> A note on SQLObject limitations
> SQLObject wants you to think in object-oriented terms instead of relational
> terms. This is good for your comprehension and your programming
> productivity, but it's not so good for performance. After all, the database
> is still relational. How do you mark every phone number in the database as
> having been called? With SQL, you would use a single UPDATE command. With
> SQLObject, you need to iterate over the entire result set and modify the
> last_call member of each object, which is much less efficient.
> SQLObject sacrifices processor time for developer time. This is usually a
> good deal, but even in simple applications, you may need to drop down a
> level to the Python database interface and write raw SQL for some
> critical-path operations.
>
>
> [1]
> http://www.ibm.com/developerworks/opensource/library/os-pythonsqlo/#N10393
>

Si tenés consultas no triviales o actualizaciones puntuales como la
mencionada, creo que lo mejor sería una biblioteca de acceso a datos,
a.k.a. DAL (database access library) como la que se usa en web2py:

http://www.latinuxpress.com/books/drafts/web2py/caps/cap6.html

No solo es muy parecido a SQL (por lo que es muy facil de aprender) y
permite escribir consultas a bases de datos de manera pythónica y
reusable, también es rápida y flexible (por ej. permite tener campos
"calculados" o virtual fields similar al mapeo de objetos como hacen
los ORMs)

Últimamente se puede usar separadamente de web2py sin problemas, y
hasta se está hablando de liberarla como un paquete totalmente
independiente.

Sds

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com



More information about the pyar mailing list