[Python] congetture su libreria per sql

Marco Mariani marco.mariani a prometeia.it
Ven 2 Apr 2010 14:07:15 CEST


On 04/02/2010 12:13 PM, Manuele Pesenti wrote:

> Vorrei capire se sto usando un approccio strampalato... dato che in rete
> gli esempi che trovo sono pił che altro di definizione di classi ad hoc
> a seconda del problema o meglio del db con cui mi devo interfacciare.
>   

Puoi creare le classi Table al volo, SQLAlchemy interroghera'
l'information_schema del database per sapere come sono fatte, con
l'opzione 'autoload=True'. La feature si chiama anche 'reflection'.

Il metadata cosi' costruito puo' essere serializzato con Pickle, ed
utilizzato per ricreare le tabelle in un database vuoto.

I mapper, se ne hai bisogno, li puoi collegare alle tabelle successivamente.

L'ho fatto e funziona.


> Scusate se sono stato confuso...
>   

La tua necessita' non mi e' chiara al 100% ma spero di essere stato utile.

-- 
This e-mail (and any attachment(s)) is strictly confidential and for use only by intended recipient(s). Any use, distribution, reproduction or disclosure by any other person is strictly prohibited. The content of this e-mail does not constitute a commitment by the Company except where provided for in a written agreement between this e-mail addressee and the Company. If you are not an intended recipient(s), please notify the sender promptly and destroy this message and its attachments without reading or saving it in any manner. Any non authorized use of the content of this message constitutes a violation of the obligation to abstain from learning of the correspondence among other subjects, except for more serious offence, and exposes the person responsible to the relevant consequences.



Maggiori informazioni sulla lista Python