Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
soitool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bachelor-paa-bittet
soitool
Commits
9237f6ce
Commit
9237f6ce
authored
5 years ago
by
morkolai
Browse files
Options
Downloads
Patches
Plain Diff
#5 Laget mulighet for get_codebook til å både hente stor og liten kodebok
parent
8f3696d9
No related branches found
No related tags found
1 merge request
!10
Database setup
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
soitool/database.py
+21
-13
21 additions, 13 deletions
soitool/database.py
with
21 additions
and
13 deletions
soitool/database.py
+
21
−
13
View file @
9237f6ce
...
...
@@ -120,25 +120,33 @@ class Database():
return
categories
def
get_
small_
codebook
(
self
):
def
get_codebook
(
self
,
small
=
False
):
"""
Retrive the entries belonging to the small codebook.
Retrive the entries belonging to the small codebook or big codebook.
Parameters
----------
small : Bool
Full or smal codebook to be returned
Returns
-------
Lsi
t of dicts
codebook : lis
t
(
of dicts
)
[{
'
word
'
: str,
'
type
'
: str,
'
category
'
: str,
'
code
'
: str}]
"""
stmt
=
'
SELECT * FROM CodeBook WHERE Type = ?
'
queried
=
self
.
conn
.
execute
(
stmt
,
(
1
,)).
fetchall
()
# Get either small or whole codebook
stmt
=
'
SELECT * FROM CodeBook
'
if
(
small
):
stmt
=
stmt
+
'
WHERE Type = ?
'
queried
=
self
.
conn
.
execute
(
stmt
,
(
1
,)).
fetchall
()
else
:
queried
=
self
.
conn
.
execute
(
stmt
).
fetchall
()
small_
codebook
=
[]
codebook
=
[]
for
entry
in
queried
:
small_
codebook
.
append
({
'
word
'
:
entry
[
'
Word
'
],
'
category
'
:
entry
[
'
Category
'
],
'
type
'
:
entry
[
'
Type
'
],
'
code
'
:
entry
[
'
Code
'
]})
codebook
.
append
({
'
word
'
:
entry
[
'
Word
'
],
'
category
'
:
entry
[
'
Category
'
],
'
type
'
:
entry
[
'
Type
'
],
'
code
'
:
entry
[
'
Code
'
]})
return
small_
codebook
return
codebook
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment