Esempio n. 1
0
 def get_all(cls):
     query = "SELECT * FROM users;"
     results = connectToMySQL('users_schema').query_db(query)
     users = []
     for i in results:
         users.append(cls(i))
     return users
Esempio n. 2
0
 def destroy(cls, data):
     query = "DELETE FROM `users_schema`.`users` WHERE id = %(id)s;"
     return connectToMySQL('users_schema').query_db(query, data)
Esempio n. 3
0
 def update(cls, data):
     query = "UPDATE users SET `first_name`= %(first_name)s, `last_name` = %(last_name)s, `email` = %(email)s, `updated_at` = NOW() WHERE id = %(id)s;"
     return connectToMySQL('users_schema').query_db(query, data)
Esempio n. 4
0
 def get_by_id(cls, data):
     query = "SELECT * FROM users WHERE id = %(id)s;"
     results = connectToMySQL('users_schema').query_db(query, data)
     return cls(results[0])
Esempio n. 5
0
 def save(cls, data):
     query = "INSERT INTO users (`first_name`, `last_name`, `email`, `created_at`, `updated_at`) VALUES (%(first_name)s, %(last_name)s, %(email)s, NOW(), NOW())"
     return connectToMySQL('users_schema').query_db(query, data)