Ai
4 Star 1 Fork 0

wjwilliam/software_engineering-dlib_face_recognition

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Database.py 2.31 KB
一键复制 编辑 原始数据 按行查看 历史
JohnZero 提交于 2022-06-19 21:51 +08:00 . 打包EXE
import sqlite3, os
class Database():
def __init__(self):
os.makedirs('resources', exist_ok=True)
self.conn = sqlite3.connect('./resources/company.db')
def dict_factory(cursor, row):#重定义row_factory函数查询返回数据类型是字典形式
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
self.conn.row_factory = dict_factory
self.c = self.conn.cursor()
self.creatble()
def creatble(self):
self.c.execute('''CREATE TABLE IF NOT EXISTS student
(
id_number CHAR(50) NOT NULL ,
user_name CHAR(50) NOT NULL,
gender bool,
password char(20) NOT NULL,
img_path char(60),
vector blob ,
salt char(10) NOT NULL ,
count INT,
PRIMARY KEY (id_number )
)without rowid;''')
self.c.execute('''CREATE TABLE IF NOT EXISTS student_log_time
(
id_number CHAR(50) NOT NULL ,
gender bool,
type INT,
log_time datetime NOT NULL
);''')
# self.c.execute('''CREATE TABLE IF NOT EXISTS admin
# (
# id_number CHAR(50) NOT NULL ,
#
#
# password char(20) NOT NULL,
# salt char(10) NOT NULL ,
# vector blob ,
# PRIMARY KEY (id_number )
# )without rowid;''')
# self.c.execute('''CREATE TABLE IF NOT EXISTS admin_log_time
# (
# id_number CHAR(50) NOT NULL ,
#
# log_time datetime NOT NULL
#
#
# );''')
self.conn.commit()
def insert_user(self, id_number, user_name,gender, password, img_path, vector,
salt):
self.c.execute(
"INSERT INTO student (id_number,user_name,gender,password ,img_path ,vector,salt) \
VALUES (?,?, ?, ? , ?,?,?)",
(id_number, user_name,gender, password, img_path, vector, salt))
self.conn.commit()
def delete(self, id):
self.c.execute("delete from student where id_number = {0}".format(id))
self.conn.commit()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wjwilliam/software_engineering-dlib_face_recognition.git
git@gitee.com:wjwilliam/software_engineering-dlib_face_recognition.git
wjwilliam
software_engineering-dlib_face_recognition
software_engineering-dlib_face_recognition
master

搜索帮助