windows - python 查询sqlite数据库问题?

查看:125
本文介绍了windows - python 查询sqlite数据库问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

学习中 --建表,添加数据 都过了,

用pycharm也可以查询,操作啊!!如图:

但是用python查询数据表示报错说没有这样的表报错如图:

代码如下:

import sqlite3

conn = sqlite3.connect(r'./mytest.py')
cursor = conn.cursor()

# sql = '''select * from students'''
sql = "select rowid, * from students"

results = cursor.execute(sql)
all_students = results.fetchall()
for student in all_students:
    print(student)
    

行了没问题了 劳烦大家了!!路径问题
conn = sqlite3.connect('D:\pycharm\lesson\sn01\SQL\mytest.db')

解决方案

conn = sqlite3.connect(r'./mytest.py')
为啥连接的是py...

这篇关于windows - python 查询sqlite数据库问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆