[mod_python] SQL question

Nicolas Lehuen nicolas.lehuen at gmail.com
Wed Feb 1 12:00:40 EST 2006


There are ways, but they are all platform dependent.

- you can query the system tables of your database. Those system
tables usually contain meta-data about the user tables. Their name and
content is highly dependent on the DBMS your are using, however.

- some DBAPI implementation provide abstraction above those system
tables. For instance, mxODBC gives a few additional methods (which are
not in the DBAPI spec) to get the name of the tables, their primary
and foreign keys, etc. This is due to the ODBC API which asks their
implementors to provide an abstraction over meta-data.

What are your DBMS and DBAPI implementation ?

Regards,
Nicolas


2006/2/1, Luis M. Gonzalez <luismg at gmx.net>:
>
> Hi folks,
>
> First of all, let me apologize for asking a question that is not specific to
> mod_python,
> but I think that it could be of interest to many of you:
>
> I wrote a script that creates authomatic administration pages for databases.
> For a given database, whose name is pased as parameter to the script, a
> fully functional administration interface is created.
> This interface allows me to insert, update or delete records in any table of
> the database, and all these actions are accessed through a web page with
> links
> to each of the database's tables.
>
> There's only one problem with it.
> The script assumes that the first field of each table is a primary key, and
> this is necessary for performing updates on the table.
> In those cases where the tables don't have a primary key, or when the
> primary key is composed of two fields, the update cannot be performed
> correctly.
>
> The question is:
> Is there any way to figure out the primary key of a table?
> Perhaps through a special type of query or function?
> I've been reading the mysql documentation but I couldn't find any solution,
> although I'm sure there might be a simple way to do it...
>
> Any hint would be highly appreciated...
> If anyone wants to check the script, I'd be glad to send it by email.
>
> Regards,
> Luis
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>



More information about the Mod_python mailing list