def get_expenses(): conn = pg.connect(dbname='postgres', user='******', password='******', host='192.168.99.102') cur = conn.cursor() cur.execute("SELECT * FROM byte_store") trs = cur.fetchall() trs = [pickle.loads(bytes(i[0])) for i in trs] schema = ExpenseSchema(many=True) expenses = schema.dump( filter(lambda t: t.type == TransactionType.EXPENSE, trs) ) resp = json.dumps(expenses.data, sort_keys = True, indent = 4, separators = (',', ': ')) return current_app.response_class(resp, mimetype="application/json")
def get_expenses(): schema = ExpenseSchema(many=True) expenses = schema.dump( filter(lambda t: t.type == TransactionType.EXPENSE, transactions) ) return jsonify(expenses.data)
def get_expenses(): #seleciona todas as transacoes com o tipo INCOME schema = ExpenseSchema(many=True) expenses = schema.dump( filter(lambda t: t.type == TransactionType.EXPENSE, transactions)) return jsonify(expenses.data)