1 Star 0 Fork 109

deathmask / facenet_face_recognition

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
face_mysql.py 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
爿臣戈王耑 提交于 2017-11-21 14:21 . init project
# -*- coding:utf-8 -*-
import mysql.connector
import datetime
class face_mysql:
def __init__(self):
pass
#设置数据库和密码
def conn_mysql(self):
db = mysql.connector.connect(user='root', password='123456', host='127.0.0.1', database='face_data')
return db
def insert_facejson(self, pic_name, pic_json, uid, ugroup):
db = self.conn_mysql()
cursor = db.cursor()
dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
sql = "insert into face_json(json,pic_name,date,state,uid,ugroup) values('%s' ,'%s','%s','%d','%s','%s') ;" % (
pic_json, pic_name, dt, 1, uid, ugroup)
#print("sql=",sql)
try:
# 执行sql语句
cursor.execute(sql)
# 提交到数据库执行
lastid = int(cursor.lastrowid)
db.commit()
except:
# Rollback in case there is any error
db.rollback()
db.close()
return lastid
def findall_facejson(self, ugroup):
db = self.conn_mysql()
cursor = db.cursor()
sql = "select * from face_json where state=1 and ugroup= '%s' ;" % (ugroup)
try:
cursor.execute(sql)
results = cursor.fetchall()
return results
except:
print("Error:unable to fecth data")
db.close()
Python
1
https://gitee.com/deathmask/facenet_face_regonistant.git
git@gitee.com:deathmask/facenet_face_regonistant.git
deathmask
facenet_face_regonistant
facenet_face_recognition
master

搜索帮助