bbdd
index
 
Classes
 
class UsersDDBB
    Class to deal with users who can access to the application.
Here, we can create/delete the database, inizialize/close the connections,
    add/delete users and change passwords. All users who are included in this
    database can access to the application. 
The database which is created is called users.db, and can be found inside BBDD.
The name of the table is "USERS".
 
  Methods defined here:
__init__(self)
Inizializes the connection to the ddbb in which the users are defined
The self is defined
changePass(self, user, newpass)
Changes the password assigned to a specific user 
 
Args:
    user: this is the username related to the user who wants to change 
        his/her password.
    newpassword: new password
closeCon(self)
Closes the connection
createTables(self)
Creates table if it doesnt exist.
This option is never used for the application, but it is appropriate 
    to have a method which allows us to create the table if it has been 
    removed.
deleteUs(self, user)
This method allows to delete an existing user. However, the application
    does not allow to do this, so this accion must be done at the 
    command line. 
    
Args:
    user: this will be the user to be deleted from the table
dropTables(self)
This method removes the table "USERS". It is not convenient to use this
    method.
insUs(self, user, password)
This method inserts a new user inside the table.
This method will be called once a user tries to sign up.
 
Args:
    user: this will be the username
    password: this will be the password which will allow
        the user to get logged in.
restart(self)
Restarts the connection to the database
showUsers(self)
This method shows all the users included inside the table.
 
Returns:
    listUsers: List in which all the users are included. Every user is 
        added as a list: [username,password]

 
class WordsDDBB
    Class to deal with the words that every user include in their databases. 
Here, we can insert/delete the database, inizialize/close the connections,
    add/delete words and change passwords. 
The database which is created is the name of the user, and each user has 
    his/her own database. 
The name of the table is "WORDS".
 
  Methods defined here:
__init__(self, username)
Inizializes the connection to a specific ddbb .
The self is defined.
The name of the database is defined here, and it is defined as a class 
    variable. The connection is kept opened to allow the user to 
    execute another actions inside this database. It is necessary to 
    close the connection through the method closeCon(). 
    
Args:
    username: name of the database
closeCon(self)
Closes the connection
createTables(self)
Creates the table if it doesnt exist.
This table is created when the database is created (after the signup)
deleteWord(self, word)
This method allows to delete an existing word. 
 
Args:
    word: word that the user ask to delete
dropTables(self)
This method removes the table "USERS". It is not convenient to use this
    method.
fileToImport(self, file)
Inizializes the connection to an external ddbb and open the connection. 
    It is important to know that the actions to be performed later will 
    be done inside this database if it is not closed through the method 
    closeCon(). 
 
Args:
    file: database file
insWord(self, word, example, meaning, syntaxis, category, when)
This method inserts a new word inside the table.
 
Args:
    word: new word to be included
    example: example in which the word is used
    meaning: meaning of the word in the user's native language
    syntaxis: type of word (verb, preposition...)
    category: level. By default, all words are iniziated with the first 
        level.
    when: day in which the word is created.
resetLevels(self)
Updates the level associated with all the words to 1
restart(self)
Restarts the connection
showAll(self)
This method shows all the words included in a specific database.
 
Returns:
    listWords: List in which all the words are included. Every word is 
        added as a list: 
        [word, example, meaning, word type,level,creation day]
 
Note: We have to take into account that the same word can have different
    inputs associated with different meanings or word types.
showWord(self, word)
This method shows all the words associated with a specific word name.
 
Args:
    word: This method will show the words with this name.
    
Returns:
    listWords: List in which all the words meeting the requirement are 
        included. Every word is added as a list: 
        [word, example, meaning, word type,level,creation day]
 
Note: We have to take into account that the same word can have different
    inputs associated with different meanings or word types.
showWords(self)
This method shows all the words  included inside the table.
 
Returns:
    listWords: List in which all the word are included. They are ordered 
        depending on its word name. Every word is added as a list: 
        [word, example, meaning, word type,level,creation day]
showWordsAllLevels(self)
This method allows to show how many words there are for each level
 
Returns:
    stats: dictionary in which we show the level and the number of words
        included inside that level.
    totalWords: total number of words, regardless the level.
showWordsAllTypes(self)
This method allows to show how many words there are for each word type
 
Returns:
    stats: dictionary in which we show the word type and the number of 
    words included inside that type.
    totalWords: total number of words, regardless the word type.
showWordsByLevel(self, level)
This method shows all the words associated with a specific level.
 
Args:
    level: This method will show the words with this level.
    
Returns:
    listWords: List in which all the words meeting the requirement are 
        included. Every word is added as a list: 
        [word, example, meaning, word type,level,creation day]
showWordsByLevelwordType(self, level, wordType)
This method shows all the words associated with a specific level and 
    word type.
 
Args:
    wordType: This method will show the words with this word type.
    level: This method will show the words with this level.
    
Returns:
    listWords: List in which all the words meeting the requirement are 
        included. Every word is added as a list:  
        [word, example, meaning, word type,level,creation day]
showWordswordType(self, wordType)
This method shows all the words associated with a specific word type.
 
Args:
    wordType: This method will show the words with this word type.
    
Returns:
    listWords: List in which all the words meeting the requirement are 
        included. Every word is added as a list: 
        [word, example, meaning, word type,level,creation day]
updateLevel(self, word, meaning, newLevel)
Changes the level assigned to a specific word
 
Args:
    word: word whose level will be updated.
    meaning: meaning of word whose level will be updated.
    newLevel: new level