hey all, I'm pretty new to elixir (and python). I'm trying to figure out how to query my new table.
I've got a model that looks like this (it's in it's own folder called 'model', the file is called 'demographic.py') *from elixir import ** * * *metadata.bind = 'mysql://root:THEPASSWORD@localhost/test'* *metadata.bind.echo = True* * * *class Demographic(Entity):* * name = Field(Unicode(30))* * yob = Field(Integer)* * description = Field(UnicodeText)* * * * def __repr__(self):* * if (self.yob is None):* * self.yob = 0000* * return '<Demographic "%s" (%d)>' % (self.name, self.yob)* I've got another file that imports the demographic and then tries to query and get all of the entries: *from model import demographic* * * *...* * * *def get_demographic():* * patients = demographic.Demographic.query.all()* * print patients* However, I'm getting the following error: *AttributeError: type object 'Demographic' has no attribute 'query'* When I add 'demographic.setup_all()' to the start of the get_demographic() function, it works. Do I need to call 'demographic.setup_all()' every time I want to query? Thanks all! Cheers -- Jarrett Chisholm -- You received this message because you are subscribed to the Google Groups "SQLElixir" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlelixir/-/OFRg1oADNzEJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlelixir?hl=en.
