messenger_server.database module¶
-
exception
messenger_server.database.ContactExistingError¶
-
class
messenger_server.database.DatabaseConnection¶ Single SQLite3 Database connection.
Parameters: - _connection (
sqlite3.Connection) – Connection object for the database - _cursor (
sqlite3.Cursor) – Cursor object returned by _connection
-
add_contact(user, contact)¶ Insert a record representing a (user, contact) pair.
Parameters: - user (str) – Login of user who is adding a new contact
- contact (str) – Login of user who is being added as contact
Raises: messenger_server.database.ContactExistingErrorif such pair already exists in the databaseRaises: messenger_server.database.UserNotFoundErrorif contact does not exist in the users table
-
add_user(email, login, password)¶ Insert a record representing a single user.
Parameters: - email (str) – User’s email address
- login (str) – User’s login
- password (str) – User’s password
Raises: messenger_server.database.LoginTakenErrorif a record with identical login already exists
-
get_contacts_list(user)¶ Get a list of given user’s contacts.
Parameters: user (str) – Login of user whose contacts are being retrieved Returns: a list of logins Return type: list(str)
-
get_users_with_contact(contact)¶ Get a list of users who have given contact.
Parameters: contact (str) – Login of user being searched as a contact Returns: a list of logins Return type: list(str)
-
setup()¶ Prepare initial database structure in case it doesn’t exist yet.
This method should be called once before starting the server.
-
verify_login(login, password)¶ Verify if given login matches given password in the database.
Parameters: - login (str) – Login being matched
- password (str) – Password being matched
Raises: messenger_server.database.LoginNotFoundErrorif there is no record with given loginRaises: messenger_server.database.PasswordErrorif password retrieved from the database does not match the password provided
- _connection (
-
exception
messenger_server.database.LoginNotFoundError¶
-
exception
messenger_server.database.LoginTakenError¶
-
exception
messenger_server.database.NoContactsError¶
-
exception
messenger_server.database.PasswordError¶
-
exception
messenger_server.database.UserNotFoundError¶