Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any tips of tech theories about schemalchemy? #2

Open
wonderbeyond opened this issue Nov 13, 2017 · 1 comment
Open

Any tips of tech theories about schemalchemy? #2

wonderbeyond opened this issue Nov 13, 2017 · 1 comment

Comments

@wonderbeyond
Copy link
Contributor

I found SchemAlchemy can help me define a single class as an interface of both Schematics and SQLAlchemy. I love its idea and style, but I am not that confident since I don't understand how it works.

Any tips? many thanks!

@wonderbeyond wonderbeyond changed the title Some tips of tech theories about schemalchemy? Any tips of tech theories about schemalchemy? Nov 13, 2017
@lkraider
Copy link
Contributor

Hi!

The main work is done by the orm.synonym machinery exposed by SQLAlchemy:
http://docs.sqlalchemy.org/en/latest/orm/mapped_attributes.html#synonyms

Most of the code deals in creating these synonyms between the Schematics accessors and the SQLAlchemy columns dynamically during class construction:

field_synonym = orm.synonym(column_name, descriptor=field_descriptor)

The Model code mostly involves populating the fields during class construction, both from code and from auto-instantiation coming from SQLAlchemy when loading from DB.

Let me know if you have other questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants