I am using cloudkitty which is rating module in OpenStacks.
But here question is regarding the SQLAlchemy and Python.
I am new to SQLAlchemy.
I need to fetch some details from a table using a API call.
So I am creating a API call which is as follows:
curl -H "X-Auth-Token: token" http://128.0.0.1:8888/v1/report/invoice?invoice_id=7b73b9644e8242b3a740afc4659d9829
Which returned the data as follows:
"[<cloudkitty.storage.sqlalchemy.models.InvoiceDetails object at 0x7ff8b1dfe2d0>]"
Code which is returning the above result is as follows:
def get_invoice(self, tenant_id=None, invoice_id=None):
model = models.InvoiceDetails
session = db.get_session()
q = session.query(model)
if tenant_id:
q = q.filter(model.tenant_id == tenant_id)
if invoice_id:
q = q.filter(model.invoice_id == invoice_id)
print q
r = q.all()
return r
Need to find the way for Fetching the value instead of object.
Any help is appreciated.
Need to return it as values instead of object.
Note:
When I was trying to print the Query and executing the same in back-end it returns results correctly.(print q)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…