sqlite - 我在做后端时遇到错误,错误是它没有显示这样的列:year(sqlite3)
问题描述
我在这里遇到问题我无法找到我的错误,我的错误显示no such column :year)
import sqlite3
def connect():
conn=sqlite3.connect("books.db")
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS book (id INTEGER PRIMARY KEY,title text,author text,year integer,isbn integer)")
conn.commit()
conn.close()
def insert(title,author,year,isbn):
conn=sqlite3.connect("books.db")
cur=conn.cursor()
cur.execute("INSERT INTO book VALUES (NULL,?,?,?,?)",(title,author,year,isbn))
conn.commit()
conn.close()
def view():
conn=sqlite3.connect("books.db")
cur=conn.cursor()
cur.execute("SELECT * FROM book")
rows=cur.fetchall()
conn.close()
return rows
def search(title="",author="",year="",isbn=""):
conn=sqlite3.connect("books.db")
cur=conn.cursor()
cur.execute("SELECT * FROM book WHERE title=? OR author=? OR year=? OR isbn=?",(title,author,year,isbn))
rows=cur.fetchall()
conn.close()
return rows
connect()
#insert("The Earth","John Smith",1918,913123133)
print(view())
print(search(author="John Smith"))
解决方案
推荐阅读
- azure - Azure Log Analytics 切换语句/模式匹配
- c++ - OpenCV 无法很好地检测特定颜色
- android - 检查开关 ui 小部件的值(如果它已打开)
- c# - 使用 gmail 套接字的 SMTP 电子邮件
- jenkins - Jenkins 构建日志显示被用户中止
- php - PHP Yii2:Google OAuth2 客户端库的不稳定行为
- javascript - 如何使用 HOC 为 react 中的组件赋值?
- sql - SQL Server 2017 选择嵌入在 JSON 字段中的 JSON
- javascript - 取消选中复选框
- java - Choco求解器中的建模约束