Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ScrapyTutorial
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
Anton Gusev
ScrapyTutorial
Commits
5fa5ff0b
Commit
5fa5ff0b
authored
5 years ago
by
Anton Gusev
Browse files
Options
Downloads
Patches
Plain Diff
add field created_at, updated_at field for AltBookConnector
parent
9be04145
No related branches found
Branches containing commit
No related tags found
2 merge requests
!5
Develop
,
!4
Develop
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/database/connectors/AltBookConnector.py
+6
-2
6 additions, 2 deletions
src/database/connectors/AltBookConnector.py
with
6 additions
and
2 deletions
src/database/connectors/AltBookConnector.py
+
6
−
2
View file @
5fa5ff0b
from
..AltConnector
import
AltConnector
from
..AltConnector
import
AltConnector
from
database.models.Book
import
Book
from
database.models.Book
import
Book
from
datetime
import
datetime
class
AltBookConnector
(
AltConnector
):
class
AltBookConnector
(
AltConnector
):
def
save_book
(
self
,
item
):
def
save_book
(
self
,
item
):
...
@@ -10,7 +10,11 @@ class AltBookConnector(AltConnector):
...
@@ -10,7 +10,11 @@ class AltBookConnector(AltConnector):
# filter item keys in table field
# filter item keys in table field
real_keys
=
Book
.
__table__
.
columns
.
keys
()
real_keys
=
Book
.
__table__
.
columns
.
keys
()
real_field
=
{
k
:
v
for
k
,
v
in
item
.
items
()
if
k
in
real_keys
}
real_field
=
{
k
:
v
for
k
,
v
in
item
.
items
()
if
k
in
real_keys
}
real_field
.
update
({
'
image_path
'
:
item
[
'
images
'
][
0
][
'
path
'
]})
real_field
.
update
({
'
image_path
'
:
item
[
'
images
'
][
0
][
'
path
'
],
'
created_at
'
:
datetime
.
utcnow
(),
'
updated_at
'
:
datetime
.
utcnow
(),
})
# TODO
sql
=
'
INSERT INTO books({keys}) VALUES({values}) ;
'
.
format
(
sql
=
'
INSERT INTO books({keys}) VALUES({values}) ;
'
.
format
(
keys
=
'
,
'
.
join
(
real_field
.
keys
()),
keys
=
'
,
'
.
join
(
real_field
.
keys
()),
...
...
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