from pony.orm import *
from datetime import datetime

class ORMFixture:

    db = Database()
    class ORMGroup(db.Entity):
        _table_ ='group_list'
        id = PrimaryKey(int, column ='group_id')
        name = Optional(str, column ='group_name')
        header = Optional(str, column ='group_header')
        footer = Optional(str, column ='group_footer')

    class ORMContact(db.Entity):
        _table_ = 'addressbook'
        id = PrimaryKey(int, column ='id')
        first_name = Optional(str, column ='firstname')
        last_name = Optional(str, column='lastname')
        deprecated = Optional(datetime, column="deprecated")

    def __init__(self, host, name, user, password):
        self.db.bind('mysql', host=host, database =name, user = user, password =password)
        self.db.generate_mapping()

    def get_group_list(self):
       list( select(g for g in ORMFixture.ORMGroup))