0
0
0ralo2021-08-21 14:03:52
Python
0ralo, 2021-08-21 14:03:52

Peewee returns None, what should I do?

In general, I have a database, the query directly returns everything correctly:

SELECT garant_id FROM "Transaction";
>>> 24245653

In python, using the peewee library, I'm trying to make the same query:
list(Transaction.select(Transaction.garant))
or
list(Transaction.select(Transaction.garant_id))
but they return , However, if you select all, not one field ( )
[<Transaction: None>]
SELECT * FROM "Transaction";
list(Transaction.select())
>>>[<Transaction: 1>]

I don't understand what's wrong, because in the documentation everything seems to work
docs

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-08-21
@0ralo

It returned a list of Transaction model objects. If you don't ask for fields, then the default will be None.

for row in list(Transaction.select(Transaction.garant_id)):
    print(row.garant_id)

Alternatively, you can define your__str__

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question