1 Star 0 Fork 0

王晓光/GeneratePrintWordPaper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sqlite_crud.py 997 Bytes
一键复制 编辑 原始数据 按行查看 历史
DawnLights 提交于 2021-11-09 18:21 . Mac和Win路径按照系统变换
import sqlite3
import platform
MAC_DB_PATH = "db/word.db"
WIN_DB_PATH = "db\\word.db"
def sql_select_new_concept(no_book, no_lesson_from, no_lesson_to):
platform_system = platform.system()
conn_path = ""
if platform_system == "Darwin":
conn_path = MAC_DB_PATH
else:
conn_path = WIN_DB_PATH
# 打开数据库
conn = sqlite3.connect(conn_path)
# 创建游标
cursor = conn.cursor()
# 查询数据
sql = "SELECT * from new_concept_word_list AS t where t.no_book = ? and t.no_lesson >= ? and t.no_lesson <= ?"
values = cursor.execute(sql, (no_book, no_lesson_from, no_lesson_to))
word_list_temp = []
for i in values:
word_list_temp.append(i)
# 关闭游标
cursor.close()
# 关闭数据库
conn.close()
# 返回数据
return word_list_temp
if __name__ == '__main__':
# 数据准备
word_list = sql_select_new_concept(1, 1, 2)
for data_line in word_list:
print(data_line)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/DawnLights/generate-print-word-paper.git
git@gitee.com:DawnLights/generate-print-word-paper.git
DawnLights
generate-print-word-paper
GeneratePrintWordPaper
master

搜索帮助