I'm investigating sqlalchemy because my recurring project at work is
to put a web frontend on a legacy database and sqlobject doesn't
handle this situation well. In particular, it requires some sort of
primary key in order to perform a mapping. Most of the databases I
work with have a few tables with no primary key, so this presents a
problem.

[1] http://www.sqlalchemy.org/docs/datamapping.myt#datamapping_association

I don't need to update the tables that don't have keys but I'd like to
present a consistent way of accessing the database to the rest of the
app. Here's an example of one of the tables:

+--------+------------------+------+-----+---------+-------+
| Field  | Type             | Null | Key | Default | Extra |
+--------+------------------+------+-----+---------+-------+
| tstamp | int(10) unsigned | NO   | MUL | 0       |       |
| asn    | int(10) unsigned | NO   |     | 0       |       |
| type   | enum('U','W')    | NO   |     | U       |       |
| count  | int(10) unsigned | NO   |     | 0       |       |
+--------+------------------+------+-----+---------+-------+

I read somewhere that sqlalchemy can handle mapping onto tables
without primary keys but the options for updating the tables are
limited. While looking through the docs I didn't see a specific
example of how to handle this situation. I did run across the example
in datamapping association[1] and it implies that I can just set the
pk as the union of the first three fields in the above example. Is
this the correct approach, or is there a better way?


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to