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
9be04145
Commit
9be04145
authored
5 years ago
by
Anton Gusev
Browse files
Options
Downloads
Patches
Plain Diff
change settings for AltConnector
parent
dc6c13b4
No related branches found
Branches containing commit
No related tags found
2 merge requests
!5
Develop
,
!4
Develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/database/AltConnector.py
+6
-7
6 additions, 7 deletions
src/database/AltConnector.py
src/settings.py
+12
-6
12 additions, 6 deletions
src/settings.py
with
18 additions
and
13 deletions
src/database/AltConnector.py
+
6
−
7
View file @
9be04145
from
scrapy.conf
import
settings
from
utils.Singleton
import
Singleton
import
MySQLdb
as
sql
import
os
class
AltConnector
(
metaclass
=
Singleton
):
...
...
@@ -10,12 +9,12 @@ class AltConnector(metaclass=Singleton):
@staticmethod
def
get_connection
():
if
not
AltConnector
.
__connection
:
# TODO cant use db-port
AltConnector
.
__connection
=
sql
.
connect
(
os
.
getenv
(
'
DB_HOST
'
)
,
os
.
getenv
(
'
DB_USERNAME
'
)
,
os
.
getenv
(
'
DB_PASSWORD
'
)
,
os
.
getenv
(
'
DB_DATABASE
'
)
,
settings
[
'
DB_HOST
'
]
,
settings
[
'
DB_USERNAME
'
]
,
settings
[
'
DB_PASSWORD
'
]
,
settings
[
'
DB_DATABASE
'
]
,
charset
=
'
utf8
'
,
port
=
int
(
os
.
getenv
(
'
DB_PORT
'
)))
port
=
settings
[
'
DB_PORT
'
]
)
return
AltConnector
.
__connection
This diff is collapsed.
Click to expand it.
src/settings.py
+
12
−
6
View file @
9be04145
...
...
@@ -97,13 +97,19 @@ ITEM_PIPELINES = {
# HTTPCACHE_IGNORE_HTTP_CODES = []
# HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
DB_CONNECTION
=
os
.
getenv
(
'
DB_CONNECTION
'
)
DB_USERNAME
=
os
.
getenv
(
'
DB_USERNAME
'
)
DB_PASSWORD
=
os
.
getenv
(
'
DB_PASSWORD
'
)
DB_HOST
=
os
.
getenv
(
'
DB_HOST
'
)
DB_PORT
=
int
(
os
.
getenv
(
'
DB_PORT
'
))
DB_DATABASE
=
os
.
getenv
(
'
DB_DATABASE
'
)
CONNECTION_STRING
=
"
{drivername}://{user}:{passwd}@{host}:{port}/{db_name}?charset=utf8
"
.
format
(
drivername
=
os
.
getenv
(
'
DB_CONNECTION
'
)
,
user
=
os
.
getenv
(
'
DB_USERNAME
'
)
,
passwd
=
os
.
getenv
(
'
DB_PASSWORD
'
)
,
host
=
os
.
getenv
(
'
DB_HOST
'
)
,
port
=
os
.
getenv
(
'
DB_PORT
'
),
db_name
=
os
.
getenv
(
'
DB_DATABASE
'
)
,
drivername
=
DB_CONNECTION
,
user
=
DB_USERNAME
,
passwd
=
DB_PASSWORD
,
host
=
DB_HOST
,
port
=
str
(
DB_PORT
),
db_name
=
DB_DATABASE
,
)
# Logger config
...
...
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