ask-the-sky 2023-01-07 11:04 采纳率: 0%
浏览 13

在学习python时遇到了一个数据库的问题谁能解决下啊!

我有段代码总是报错,求教各位大神,谁能帮忙解决下啊.报错为: cu.execute('select * from ID_state where State="在线"')

sqlite3.OperationalError: no such table: ID_state

import tkinter
from tkinter import *
from tkinter import ttk
import os
import tkinter.messagebox
import sqlite3
import os.path


class Main():

    def __init__(self):
        self.ruku()

    def ruku(self):
        self.root = tkinter.Tk()
        self.root.title('入库')
        screewidth = self.root.winfo_screenwidth()
        screeheight = self.root.winfo_screenheight()
        root_width = screewidth - 50
        root_height = 650
        x = int((screewidth - root_width) / 2)
        y = int((screeheight - root_height) / 2)
        self.root.geometry('{}x{}+{}+{}'.format(root_width, root_height, x, y))
        self.root.config(bg='#87CEEB')
        mainmenu = Menu(self.root,tearoff= False)
        mainmenu.add_command(label='返回主菜单')
        mainmenu.add_command(label='退出')
        self.root.config(menu= mainmenu)

        Label(self.root,text='入库作业',font=("微软雅黑",20),fg= "grey",bg='#87CEEB').pack()#place(x=screewidth/2,y=0)
        Label(self.root, text='项', font=("微软雅黑", 20), fg="grey",bg='#87CEEB').place(x=10,y=40)
        Label(self.root, text='1', font=("微软雅黑", 20), fg="grey",bg='#87CEEB').place(x=10, y=75)
        Label(self.root, text='入库类别', font=("微软雅黑", 20), fg="grey",bg='#87CEEB').place(x=70, y=40)

        self.value_D_01 = StringVar()
        self.value_D_01.set("采购入库")
        values1 = ['采购入库', '验收入库', '上级下发入库','其它入库']
        self.combobox1 = ttk.Combobox(
            master=self.root,  # 父容器
            height=10,  # 高度,下拉显示的条目数量
            width=8,  # 宽度
            state="readonly",  # 设置状态 normal(可选可输入)、readonly(只可选)、 disabled
            cursor="arrow",  # 鼠标移动时样式 arrow, circle, cross, plus...
            font=("微软雅黑", 15),  # 字体
            textvariable=self.value_D_01,  # 通过StringVar设置可改变的值
            values=values1,  # 设置下拉框的选项
            justify='center'
        )
        self.combobox1.place(x=60, y=75)

        Label(self.root, text="入库编号", font=("微软雅黑", 15), fg="grey",bg='#87CEEB').place(x=280, y=40)
        self.D_ID = []
        conn = sqlite3.connect("./ID_state.db")
        cu = conn.cursor()
        cu.execute('select * from ID_state where State="在线"')
        E = cu.fetchall()
        conn.commit()
        cu.close
        for i in range(len(E)):
            self.D_ID.append(E[i][4])

        self.value_D_02 = StringVar()
        self.value_D_02.set("")

        self.combobox2 = ttk.Combobox(
            master=self.root,  # 父容器
            height=10,  # 高度,下拉显示的条目数量
            width=20,  # 宽度
            state="normal",  # 设置状态 normal(可选可输入)、readonly(只可选)、 disabled
            cursor="arrow",  # 鼠标移动时样式 arrow, circle, cross, plus...
            font=("微软雅黑", 15),  # 字体
            textvariable=self.value_D_02,  # 通过StringVar设置可改变的值
            values=self.D_ID,  # 设置下拉框的选项
            justify='center'
        )
        self.combobox2.place(x=190, y=75)


        self.root.mainloop()





main = Main()
  • 写回答

1条回答 默认 最新

  • 黛琳ghz 2022年度博客之星前端领域TOP 8 2023-01-07 11:21
    关注
    评论

报告相同问题?

问题事件

  • 创建了问题 1月7日

悬赏问题

  • ¥15 结构功能耦合指标计算
  • ¥50 AI大模型精调(百度千帆、飞浆)
  • ¥15 非科班怎么跑代码?如何导数据和调参
  • ¥15 福州市的全人群死因监测点死亡原因报表
  • ¥15 Altair EDEM中生成一个颗粒,并且各个方向没有初始速度
  • ¥15 系统2008r2 装机配置推荐一下
  • ¥15 悬赏Python-playwright部署在centos7上
  • ¥15 psoc creator软件有没有人能远程安装啊
  • ¥15 快速扫描算法求解Eikonal方程咨询
  • ¥15 校内二手商品转让网站