1 Star 0 Fork 0

毕业设计/online-judge-recommendation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
database.py 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
shawvey 提交于 2018-12-11 23:25 . Add files via upload
import sqlite3
class Db:
def __init__(self):
self.connection = sqlite3.connect("database/login.db")
self.createTable()
def createTable(self):
#connection = sqlite3.connect("login.db")
self.connection.execute("CREATE TABLE IF NOT EXISTS STUDENTS(USERNAME TEXT NOT NULL, PASSWORD TEXT)")
self.connection.commit()
def insertTable(self,user,password):
print(user)
print(password)
self.connection.execute("INSERT INTO STUDENTS VALUES(?,?)",(user,password))
self.connection.commit()
def loginCheck(self,username,password):
result = self.connection.execute("SELECT * FROM STUDENTS WHERE USERNAME = ? AND PASSWORD = ?",(username,password))
count = len(result.fetchall())
print(count)
#print(result.fetchall())
for data in result:
print("Username : ", data[1])
print("Password : ", data[2])
if(count > 0):
print("Login Successfully")
return True
else:
print("You havent registered yet")
return False
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ontology-edu/online-judge-recommendation.git
git@gitee.com:ontology-edu/online-judge-recommendation.git
ontology-edu
online-judge-recommendation
online-judge-recommendation
master

搜索帮助