#!/usr/bin/python3 from libraries.database.broadcasts import * import simplejson import sqlalchemy def alchemyencoder(obj): """JSON encoder function for SQLAlchemy special classes.""" if isinstance(obj, datetime.date): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return float(obj) elif isinstance(obj, sqlalchemy.orm.state.InstanceState): return "" #elif isinstance(obj, Schedule): # return simplejson.dumps([obj._asdict()], default=alchemyencoder) else: return str(obj) def select_with_relationship(): se = TrackServiceScheduleEntry.select_all() print(se) # programme_as_string = simplejson.dumps([se[0]._asdict()], default=alchemyencoder) # print(programme_as_string) # # ## ## ## ## ## # # # # ENTRY FUNCTION # # # # ## ## ## ## ## # # def main(): select_with_relationship() # # ## ## ## ## ## ## # # # # End ENTRY FUNCTION # # # # ## ## ## ## ## ## # # if __name__ == "__main__": main()