P
P
pcdesign2015-02-10 19:44:29
Flask
pcdesign, 2015-02-10 19:44:29

Why is an array returned in flask sqlalchemy?

Here is the request.

user_id = L.query.with_entities(L.user_id).filter(L.identity == j['identity'], L.provider == j['provider']).first()


Actually, I only request user_id using query.with_entities.
I even add first() at the end.

And this is what I get:
(2,)

Why (2,) instead of just 2?
And how to get just 2?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Fateev, 2015-02-11
@pcdesign

Then do it like this:
For example:
or immediately:

user_id = L.query.with_entities(L.user_id).filter(L.identity == j['identity'], L.provider == j['provider']).first()[0]

O
Oleg, 2017-10-02
@PHPjedi

https://jsfiddle.net/3t833vy7/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question