FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonMvcMySQL/Book.py at master · iandygit/PythonMvcMySQL · GitHub
iandygit
PythonMvcMySQL
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonMvcMySQL
/
Book.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (21 loc) · 807 Bytes
Breadcrumbs
PythonMvcMySQL
/
Book.py
Copy path
File metadata and controls
26 lines (21 loc) · 807 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# -*- coding: utf-8 *-*
__author__
=
'Gonzalo Chacaltana Buleje'
from
MySQLConnection
import
MySQLConnection
class
Book
:
def
__init__
(
self
):
self
.
id_book
=
0
self
.
id_category
=
''
self
.
title
=
''
self
.
price
=
''
self
.
date_created
=
'NOW()'
self
.
db
=
MySQLConnection
()
def
create
(
self
):
"""create a new record"""
query
=
"INSERT INTO books (id_book, id_category,name,price,date_created) values (null, %s, %s, %s, NOW())"
values
=
(
self
.
id_category
,
self
.
title
,
self
.
price
)
self
.
db
.
execute
(
query
,
values
)
self
.
db
.
commit
(
query
)
def
read_all
(
self
):
query
=
"SELECT id_book,id_category,name FROM books;"
self
.
db
.
execute
(
query
)
return
self
.
db
.
get_fetch_rows
()
Back
|
FazBrowse Home
|
New Git URL