can you show us an example of a particular object relationship and the
tables you want it to map to ?  the simplest of course is one object per
table.


Jonathan Hayward http://JonathansCorner.com wrote:
> I am trying to retrofit an existing application to use SQLalchemy; it uses
> its own database which is painfully slow.
>
> I am presently trying to get lists working correctly; objects have lists
> of
> strings/other objects, and so I am trying to make a separate table for
> each
> list item, so that a row in the secondary table which has the foreign
> primary key of the object that has the list item, and the string/primary
> key
> of what it is that is listed.
>
> Question: once I have done that, how do I set up a function to translate
> from the existing object to the table row? Or perhaps a better question to
> ask is, should I be trying to create a micromanaging function that will
> step
> by step convert my object to a number of database tables, or am I missing
> a
> way that the Mapper should be able to handle that?
>
> My (pseudo)-code for now is (corrections welcome):
>
>         document_table = sqlalchemy.Table("document", \
>           sqlalchemy.Column("file_contents", sqlalchemy.String), \
>           sqlalchemy.Column("filename", sqlalchemy.String), \
>           sqlalchemy.Column("html_name", sqlalchemy.String, \
>             primary_key = True), \
>           sqlalchemy.Column("last_modified", sqlalchemy.Datetime), \
>           sqlalchemy.Column("last_viewed", sqlalchemy.Datetime), \
>           sqlalchemy.Column("permanent_ID", sqlalchemy.String), \
>           sqlalchemy.Column("relative_filename", sqlalchemy.String), \
>           sqlalchemy.Column("root", sqlalchemy.String), \
>           sqlalchemy.Column("section", sqlalchemy.String), \
>           sqlalchemy.Column("text", sqlalchemy.String), \
>           sqlalchemy.Column("title", sqlalchemy.String), \
>           sqlalchemy.Column("tokens", sqlalchemy.String), \
>           sqlalchemy.Column("version", sqlalchemy.Integer), \
>           )
>         histogram_table = sqlalchemy.Table("histogram", \
>           sqlalchemy.Column("html_name", sqlalchemy.String, \
>             foreignkey("document.html_name")), \
>           sqlalchemy.Column("word", sqlalchemy.String), \
>           sqlalchemy.Column("count", sqlalchemy.Integer),
>           )
>         histogram_total_table = sqlalchemy.Table("histogram_total", \
>           sqlalchemy.Column("html_name", sqlalchemy.String, \
>             foreignkey("document.html_name")), \
>           sqlalchemy.Column("count", sqlalchemy.Integer),
>           )
>         aliases_table = sqlalchemy.Table("aliases", \
>           sqlalchemy.Column("old", sqlalchemy.String), \
>           sqlalchemy.Column("new", sqlalchemy.String) \
>           )
>         # identifier is primary key
>         section_table = sqlalchemy.Table("section", \
>           #sqlalchemy.Column("documents", sqlalchemy.String), \
>           sqlalchemy.Column("html_name", sqlalchemy.String, \
>             primary_key = True), \
>           sqlalchemy.Column("parent", sqlalchemy.String), \
>           sqlalchemy.Column("root", sqlalchemy.String),
>           #sqlalchemy.Column("subsections",
> LIST_OF_IDENTIFIER_PRIMARY_KEYS), \
>           #sqlalchemy.Column("text_patterns_to_accept", LIST_OF_STRINGS),
> \
>           #sqlalchemy.Column("text_patterns_to_deny", LIST_OF_STRINGS), \
>           sqlalchemy.Column("url_prefix", sqlalchemy.String), \
>           sqlalchemy.Column("url_root", sqlalchemy.String) \
>           )
>         section_table_documents("section_table_documents", \
>           sqlalchemy.Column("section_html_name", sqlalchemy.String), \
>           sqlalchemy.Column("document_html_name", sqlalchemy.String) \
>           )
>         section_table_subsections("section_table_subsections", \
>           sqlalchemy.Column("section_html_name", sqlalchemy.String), \
>           sqlalchemy.Column("subsection_html_name", sqlalchemy.String) \
>           )
>         section_table_text_patterns_to_accept( \
>           "section_table_text_patterns_to_accept", \
>           sqlalchemy.Column("section_html_name", sqlalchemy.String), \
>           sqlalchemy.Column("text_pattern_to_accept", sqlalchemy.String) \
>           )
>         section_table_text_patterns_to_deny( \
>           "section_table_text_patterns_to_deny", \
>           sqlalchemy.Column("section_html_name", sqlalchemy.String), \
>           sqlalchemy.Column("text_pattern_to_deny", sqlalchemy.String) \
>           )
>
>
> --
> ++ Jonathan Hayward, [EMAIL PROTECTED]
> ** To see an award-winning website with stories, essays, artwork,
> ** games, and a four-dimensional maze, why not visit my home page?
> ** All of this is waiting for you at http://JonathansCorner.com
>
> ** If you'd like a Google Mail (gmail.com) account, please tell me!
>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to