我使用Python的peeweeorm来处理MySQL数据库。Peewee提供了一个名为“fn”的对象,允许您对数据库进行某些类型的调用。我想打的其中一个电话是:Blocks.select(Blocks, fn.Count(Blocks.height))
其中Blocks是数据库中的一个表,其中有一个名为height的列。这个语法直接取自Peewee的文档,即
^{pr2}$
import peewee
from peewee import *
from peewee import fn
但是当我运行这个代码时,它不起作用,它会把这个吐出来 SELECT t1.`height`, t1.`hash`, t1.`time`, t1.`confirmations`, t1.`size`, t1.`version`, t1.`merkleRoot`, t1.`numTX`, t1.`nonce`, t1.`bits`, t1.`difficulty`, t1.`chainwork`, t1.`previousBlockHash`, t1.`nextBlockHash`, Count(t1.`height`) FROM `blocks` AS t1 []
所以这实际上只是打印出select查询返回的列名。在
我需要编写什么样的代码才能返回表中的行数计数?我很后悔使用peewee,因为它使原本简单的查询很难找到正确的语法。在