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

Is there a way to support alternate column names? #75

Closed
n8henrie opened this issue Sep 11, 2020 · 2 comments
Closed

Is there a way to support alternate column names? #75

n8henrie opened this issue Sep 11, 2020 · 2 comments
Labels
question Further information is requested

Comments

@n8henrie
Copy link

I have a table that I'm trying to adapt from sqlalchemy in which a column name is a Python keyword (open). In my sqlalchemy table, I use open_ = Column("open", Float) so as to avoid overriding the keyword.

In my orm.Model, I'm unable to find a way to have an equivalent mapping of the mymodel.open_ object.

I tried open_ = orm.Float(name="open") but that isn't a supported kwarg.

open_ = orm.Float(title="open") doesn't work, resulting in asyncpg.exceptions.UndefinedColumnError: column tiingo_daily_historical.open_

Am I overlooking a way to do this?

Many thanks in advance!

@collerek

This comment has been minimized.

@aminalaee aminalaee added the question Further information is requested label Sep 1, 2021
@aminalaee
Copy link
Member

aminalaee commented Sep 25, 2021

With orm version 2 this is possible:

class Note(orm.Model):
    tablename = "notes"
    registry = models
    fields = {
        "id": orm.Integer(primary_key=True),
        "text": orm.String(max_length=100),
        "completed": orm.Boolean(default=False),
    }

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

No branches or pull requests

3 participants