首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python3 sqlite3查询问题:没有错误,但c.fetchall和行数为null

Python3 sqlite3查询问题:没有错误,但c.fetchall和行数为null
EN

Stack Overflow用户
提问于 2020-04-21 19:07:04
回答 1查看 17关注 0票数 0

来自itertools导入分组的mport sqlite3

桌面=r‘C:\用户\桌面\ aes_fault_db Cases\9V-SHD_20200313_0007\AES\Maintenance\AESFault_1.sqlite3’

def create_connection(aes_fault_db):

代码语言:javascript
复制
try:
    conn = sqlite3.connect(aes_fault_db)

except Error as e:
    print(e)

c = connection.cursor()
c.execute('SELECT recordid, record_type, modman_ticks, modman_date, modman_time, modman_power_on_counter,',
          'modman_flight_cycle_ounter, modman_latitude, modman_longitude, modman_altitude,',
          'modman_ground_speed, modman_aircraft_id, modman_flight_leg, L1_code, L2_code,',
          'L3_code, L4_code, L1_text, L2_text, L3_text, L4_text, additional_text,',
          'lru_recorded_temperature, lru_time, lru_antenna_azimuth, lru_antenna_elev * FROM aes_fault')
data = c.fetchall()
if data == None:
    print('no results for this query')
dataSize = c.rowcount
print(c.rowcount)
print(data)
for row in data:
    print(row)

c.close
EN

回答 1

Stack Overflow用户

发布于 2020-04-21 20:18:37

你怎么能不收到错误呢?sqlite3应该抱怨“函数最多接受2个参数(给定了5个)”。该长sql字符串中的每个逗号(,)分隔一个参数。用一组"""封装整个sql。这意味着删除所有的单引号和行尾逗号。

这里还有一个语法错误,lru_antenna_elev * FROM aes_fault'

如果您需要表中的所有列(*),那么SELECT * from aes_fault就是您需要的全部。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61342071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档