Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CSB Store App
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Joona Erkkilä
CSB Store App
Commits
5451822b
Commit
5451822b
authored
1 year ago
by
Joona Erkkilä
Browse files
Options
Downloads
Patches
Plain Diff
Update setup.py
parent
254d20b0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
setup.py
+38
-1
38 additions, 1 deletion
setup.py
with
38 additions
and
1 deletion
setup.py
+
38
−
1
View file @
5451822b
...
...
@@ -16,7 +16,18 @@ def create_tables():
)
'''
)
### Fix for the broken access control:
# connection.execute(
# '''
# CREATE TABLE IF NOT EXISTS Users (
# id INTEGER PRIMARY KEY AUTOINCREMENT,
# username TEXT NOT NULL,
# password TEXT NOT NULL,
# role TEXT NOT NULL
# )
# '''
# )
###
connection
.
execute
(
'''
CREATE TABLE IF NOT EXISTS Users (
...
...
@@ -65,6 +76,32 @@ def register_users():
finally
:
connection
.
close
()
def
register_products
():
connection
=
sqlite3
.
connect
(
database
)
try
:
with
connection
:
cursor
=
connection
.
cursor
()
products
=
[
{
'
name
'
:
'
Product1
'
,
'
price
'
:
"
5.5
"
},
{
'
name
'
:
'
Product2
'
,
'
price
'
:
"
19.99
"
},
{
'
name
'
:
'
Product3
'
,
'
price
'
:
"
8.0
"
}
]
for
product
in
products
:
cursor
.
execute
(
"
SELECT COUNT(*) FROM Products WHERE name = ?
"
,
(
product
[
'
name
'
],))
count
=
cursor
.
fetchone
()[
0
]
if
count
>
0
:
print
(
"
Product already exists.
"
)
else
:
cursor
.
execute
(
"
INSERT INTO Products (name, price) VALUES (?, ?)
"
,
(
product
[
'
name
'
],
product
[
'
price
'
]))
finally
:
connection
.
close
()
if
__name__
==
'
__main__
'
:
create_tables
()
register_users
()
register_products
()
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