-
Notifications
You must be signed in to change notification settings - Fork 0
/
bbdd.html
218 lines (186 loc) · 17.6 KB
/
bbdd.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>BrushUp!: module bbdd</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>bbdd</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href="index.html">index</a><br></font></td></tr></table>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="UsersDDBB">class <strong>UsersDDBB</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Class to deal with users who can access to the application.<br>
Here, we can create/delete the database, inizialize/close the connections,<br>
add/delete users and change passwords. All users who are included in this<br>
database can access to the application. <br>
The database which is created is called users.db, and can be found inside BBDD.<br>
The name of the table is "USERS".<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="UsersDDBB-__init__"><strong>__init__</strong></a>(self)</dt><dd><tt>Inizializes the connection to the ddbb in which the users are defined<br>
The self is defined</tt></dd></dl>
<dl><dt><a name="UsersDDBB-changePass"><strong>changePass</strong></a>(self, user, newpass)</dt><dd><tt>Changes the password assigned to a specific user <br>
<br>
Args:<br>
user: this is the username related to the user who wants to change <br>
his/her password.<br>
newpassword: new password</tt></dd></dl>
<dl><dt><a name="UsersDDBB-closeCon"><strong>closeCon</strong></a>(self)</dt><dd><tt>Closes the connection</tt></dd></dl>
<dl><dt><a name="UsersDDBB-createTables"><strong>createTables</strong></a>(self)</dt><dd><tt>Creates table if it doesnt exist.<br>
This option is never used for the application, but it is appropriate <br>
to have a method which allows us to create the table if it has been <br>
removed.</tt></dd></dl>
<dl><dt><a name="UsersDDBB-deleteUs"><strong>deleteUs</strong></a>(self, user)</dt><dd><tt>This method allows to delete an existing user. However, the application<br>
does not allow to do this, so this accion must be done at the <br>
command line. <br>
<br>
Args:<br>
user: this will be the user to be deleted from the table</tt></dd></dl>
<dl><dt><a name="UsersDDBB-dropTables"><strong>dropTables</strong></a>(self)</dt><dd><tt>This method removes the table "USERS". It is not convenient to use this<br>
method.</tt></dd></dl>
<dl><dt><a name="UsersDDBB-insUs"><strong>insUs</strong></a>(self, user, password)</dt><dd><tt>This method inserts a new user inside the table.<br>
This method will be called once a user tries to sign up.<br>
<br>
Args:<br>
user: this will be the username<br>
password: this will be the password which will allow<br>
the user to get logged in.</tt></dd></dl>
<dl><dt><a name="UsersDDBB-restart"><strong>restart</strong></a>(self)</dt><dd><tt>Restarts the connection to the database</tt></dd></dl>
<dl><dt><a name="UsersDDBB-showUsers"><strong>showUsers</strong></a>(self)</dt><dd><tt>This method shows all the users included inside the table.<br>
<br>
Returns:<br>
listUsers: List in which all the users are included. Every user is <br>
added as a list: [username,password]</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="WordsDDBB">class <strong>WordsDDBB</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Class to deal with the words that every user include in their databases. <br>
Here, we can insert/delete the database, inizialize/close the connections,<br>
add/delete words and change passwords. <br>
The database which is created is the name of the user, and each user has <br>
his/her own database. <br>
The name of the table is "WORDS".<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="WordsDDBB-__init__"><strong>__init__</strong></a>(self, username)</dt><dd><tt>Inizializes the connection to a specific ddbb .<br>
The self is defined.<br>
The name of the database is defined here, and it is defined as a class <br>
variable. The connection is kept opened to allow the user to <br>
execute another actions inside this database. It is necessary to <br>
close the connection through the method <a href="#WordsDDBB-closeCon">closeCon</a>(). <br>
<br>
Args:<br>
username: name of the database</tt></dd></dl>
<dl><dt><a name="WordsDDBB-closeCon"><strong>closeCon</strong></a>(self)</dt><dd><tt>Closes the connection</tt></dd></dl>
<dl><dt><a name="WordsDDBB-createTables"><strong>createTables</strong></a>(self)</dt><dd><tt>Creates the table if it doesnt exist.<br>
This table is created when the database is created (after the signup)</tt></dd></dl>
<dl><dt><a name="WordsDDBB-deleteWord"><strong>deleteWord</strong></a>(self, word)</dt><dd><tt>This method allows to delete an existing word. <br>
<br>
Args:<br>
word: word that the user ask to delete</tt></dd></dl>
<dl><dt><a name="WordsDDBB-dropTables"><strong>dropTables</strong></a>(self)</dt><dd><tt>This method removes the table "USERS". It is not convenient to use this<br>
method.</tt></dd></dl>
<dl><dt><a name="WordsDDBB-fileToImport"><strong>fileToImport</strong></a>(self, file)</dt><dd><tt>Inizializes the connection to an external ddbb and open the connection. <br>
It is important to know that the actions to be performed later will <br>
be done inside this database if it is not closed through the method <br>
<a href="#WordsDDBB-closeCon">closeCon</a>(). <br>
<br>
Args:<br>
file: database file</tt></dd></dl>
<dl><dt><a name="WordsDDBB-insWord"><strong>insWord</strong></a>(self, word, example, meaning, syntaxis, category, when)</dt><dd><tt>This method inserts a new word inside the table.<br>
<br>
Args:<br>
word: new word to be included<br>
example: example in which the word is used<br>
meaning: meaning of the word in the user's native language<br>
syntaxis: type of word (verb, preposition...)<br>
category: level. By default, all words are iniziated with the first <br>
level.<br>
when: day in which the word is created.</tt></dd></dl>
<dl><dt><a name="WordsDDBB-resetLevels"><strong>resetLevels</strong></a>(self)</dt><dd><tt>Updates the level associated with all the words to 1</tt></dd></dl>
<dl><dt><a name="WordsDDBB-restart"><strong>restart</strong></a>(self)</dt><dd><tt>Restarts the connection</tt></dd></dl>
<dl><dt><a name="WordsDDBB-showAll"><strong>showAll</strong></a>(self)</dt><dd><tt>This method shows all the words included in a specific database.<br>
<br>
Returns:<br>
listWords: List in which all the words are included. Every word is <br>
added as a list: <br>
[word, example, meaning, word type,level,creation day]<br>
<br>
Note: We have to take into account that the same word can have different<br>
inputs associated with different meanings or word types.</tt></dd></dl>
<dl><dt><a name="WordsDDBB-showWord"><strong>showWord</strong></a>(self, word)</dt><dd><tt>This method shows all the words associated with a specific word name.<br>
<br>
Args:<br>
word: This method will show the words with this name.<br>
<br>
Returns:<br>
listWords: List in which all the words meeting the requirement are <br>
included. Every word is added as a list: <br>
[word, example, meaning, word type,level,creation day]<br>
<br>
Note: We have to take into account that the same word can have different<br>
inputs associated with different meanings or word types.</tt></dd></dl>
<dl><dt><a name="WordsDDBB-showWords"><strong>showWords</strong></a>(self)</dt><dd><tt>This method shows all the words included inside the table.<br>
<br>
Returns:<br>
listWords: List in which all the word are included. They are ordered <br>
depending on its word name. Every word is added as a list: <br>
[word, example, meaning, word type,level,creation day]</tt></dd></dl>
<dl><dt><a name="WordsDDBB-showWordsAllLevels"><strong>showWordsAllLevels</strong></a>(self)</dt><dd><tt>This method allows to show how many words there are for each level<br>
<br>
Returns:<br>
stats: dictionary in which we show the level and the number of words<br>
included inside that level.<br>
totalWords: total number of words, regardless the level.</tt></dd></dl>
<dl><dt><a name="WordsDDBB-showWordsAllTypes"><strong>showWordsAllTypes</strong></a>(self)</dt><dd><tt>This method allows to show how many words there are for each word type<br>
<br>
Returns:<br>
stats: dictionary in which we show the word type and the number of <br>
words included inside that type.<br>
totalWords: total number of words, regardless the word type.</tt></dd></dl>
<dl><dt><a name="WordsDDBB-showWordsByLevel"><strong>showWordsByLevel</strong></a>(self, level)</dt><dd><tt>This method shows all the words associated with a specific level.<br>
<br>
Args:<br>
level: This method will show the words with this level.<br>
<br>
Returns:<br>
listWords: List in which all the words meeting the requirement are <br>
included. Every word is added as a list: <br>
[word, example, meaning, word type,level,creation day]</tt></dd></dl>
<dl><dt><a name="WordsDDBB-showWordsByLevelwordType"><strong>showWordsByLevelwordType</strong></a>(self, level, wordType)</dt><dd><tt>This method shows all the words associated with a specific level and <br>
word type.<br>
<br>
Args:<br>
wordType: This method will show the words with this word type.<br>
level: This method will show the words with this level.<br>
<br>
Returns:<br>
listWords: List in which all the words meeting the requirement are <br>
included. Every word is added as a list: <br>
[word, example, meaning, word type,level,creation day]</tt></dd></dl>
<dl><dt><a name="WordsDDBB-showWordswordType"><strong>showWordswordType</strong></a>(self, wordType)</dt><dd><tt>This method shows all the words associated with a specific word type.<br>
<br>
Args:<br>
wordType: This method will show the words with this word type.<br>
<br>
Returns:<br>
listWords: List in which all the words meeting the requirement are <br>
included. Every word is added as a list: <br>
[word, example, meaning, word type,level,creation day]</tt></dd></dl>
<dl><dt><a name="WordsDDBB-updateLevel"><strong>updateLevel</strong></a>(self, word, meaning, newLevel)</dt><dd><tt>Changes the level assigned to a specific word<br>
<br>
Args:<br>
word: word whose level will be updated.<br>
meaning: meaning of word whose level will be updated.<br>
newLevel: new level</tt></dd></dl>
</body></html>