29 lines
628 B
Python
29 lines
628 B
Python
|
import DataBase
|
||
|
from User import User
|
||
|
|
||
|
|
||
|
class UserModel:
|
||
|
def getByLogin(self, login):
|
||
|
db = DataBase.GetConnection()
|
||
|
cursor = db.cursor()
|
||
|
cursor.execute("""SELECT * FROM user WHERE login=%s""", (login,))
|
||
|
row = cursor.fetchone()
|
||
|
cursor.close()
|
||
|
db.close()
|
||
|
if row:
|
||
|
return User(row[0], row[1], row[2])
|
||
|
return None
|
||
|
|
||
|
|
||
|
def haveCamera(self, user, camera):
|
||
|
db = DataBase.GetConnection()
|
||
|
cursor = db.cursor()
|
||
|
cursor.execute("""SELECT * FROM user_camera WHERE user_id=%s AND camera_id=%s""", (user.id, camera.id))
|
||
|
row = cursor.fetchone()
|
||
|
cursor.close()
|
||
|
db.close()
|
||
|
if row:
|
||
|
return True
|
||
|
return False
|
||
|
|