mySQLdb
Sibylle Koczian
Sibylle.Koczian at Bibliothek.Uni-Augsburg.de
Fri Aug 27 04:14:02 EDT 2004
m0226065 schrieb:
> so I have a mySQL server
> and mySQLdb as an interface (do I us this term correct here?) to this server
> from python
> now I have a game:
> I want to read a file into the db
> I want other data to be kept in the db from now on
>
> problem:
> since I have special things I want to do (like write a dict into a db), do I
> have to write a specialized class, derived from mySQLdb, or would that be
> dumb? I mean, I guess it would be easier to write some functions that take
> care of everything, while I just say "write this dict to that table" or
> "write this dict item to that table" and so on.
>
You can't derive a class from mySQLdb, because that is a module
containing several classes. If I understand your description correctly,
you would need functions that
- convert a data structure, for example a dict or a dict item, to
parameters suitable for a SQL query,
- execute (and possibly construct) the right query with those parameters.
Right? That might quite well be encapsulated into a class, but I don't
think such a class would have an "is-a" relationship to a MySQLdb class.
I'd rather give it a MySQLdb.cursor and possibly a MySQL.connection
instance as attributes.
Koczian
--
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg
Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : Sibylle.Koczian at Bibliothek.Uni-Augsburg.DE
More information about the Python-list
mailing list