Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Analysis of Chatbot and Produce a Predictable reason and feedback code
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-298
Analysis of Chatbot and Produce a Predictable reason and feedback code
Commits
4e51e1a0
Commit
4e51e1a0
authored
Nov 13, 2022
by
Karagoda Gamage Pasan Malaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
9c337acb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
db.py
db.py
+47
-0
No files found.
db.py
0 → 100644
View file @
4e51e1a0
import
sqlite3
import
model
class
DB
:
def
__init__
(
self
):
self
.
_conn
=
sqlite3
.
connect
(
'database.db'
,
check_same_thread
=
False
)
self
.
_c
=
self
.
_conn
.
cursor
()
# run this method only once
def
create_table_feedback
(
self
):
self
.
_c
.
execute
(
"""CREATE TABLE feedbacks(
id integer PRIMARY KEY,
leave_date text,
real_reason text,
comment text
)"""
)
self
.
_conn
.
commit
()
def
select_feedbacks
(
self
):
self
.
_c
.
execute
(
"SELECT * FROM feedbacks"
)
feedbacks
=
self
.
_c
.
fetchall
()
returnFeedbackList
=
[]
for
i
in
range
(
0
,
len
(
feedbacks
)):
returnFeedbackList
.
append
(
model
.
Feedback
(
feedbacks
[
i
][
0
],
feedbacks
[
i
][
1
],
feedbacks
[
i
][
2
],
feedbacks
[
i
][
3
]))
return
returnFeedbackList
def
save_feedback
(
self
,
id
,
leave_date
,
real_reason
,
comment
):
try
:
sql
=
"INSERT INTO feedbacks (id, leave_date, real_reason, comment) "
\
"VALUES (?, ?, ?, ?)"
val
=
(
id
,
leave_date
,
real_reason
,
comment
)
self
.
_c
.
execute
(
sql
,
val
)
self
.
_conn
.
commit
()
except
:
pass
def
delete_feedback
(
self
,
id
):
sql
=
'DELETE FROM feedbacks WHERE id = '
+
str
(
id
)
self
.
_c
.
execute
(
sql
)
self
.
_conn
.
commit
()
# db = DB()
# db.create_table_feedback()
# db.save_feedback(2, '2022-11-10', 'salary', 'some')
# print(db.select_feedbacks())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment