Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
esi-table-data
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esi-data-scrapping
esi-table-data
Commits
395b8217
Commit
395b8217
authored
May 23, 2017
by
Vasyl Bodnaruk
Committed by
Andrii Marynets
May 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix db
parent
7bc62183
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
106 additions
and
19 deletions
+106
-19
router.py
esi/esi/router.py
+30
-0
settings.py
esi/esi/settings.py
+4
-0
__init__.py
esi/webapp/__init__.py
+0
-0
admin.py
esi/webapp/admin.py
+0
-0
apps.py
esi/webapp/apps.py
+5
-0
__init__.py
esi/webapp/migrations/__init__.py
+0
-0
__init__.py
esi/webapp/models/__init__.py
+2
-0
news.py
esi/webapp/models/news.py
+19
-0
wp.py
esi/webapp/models/wp.py
+14
-14
router.py
esi/webapp/router.py
+23
-0
tests.py
esi/webapp/tests.py
+0
-0
views.py
esi/webapp/views.py
+0
-0
db.py
exa/exa/helpers/db.py
+4
-0
pipelines.py
exa/exa/pipelines.py
+4
-4
mobihealthnews.py
exa/exa/spiders/mobihealthnews.py
+1
-1
No files found.
esi/esi/router.py
0 → 100644
View file @
395b8217
class
EsiDatabaseRouter
:
default_apps
=
(
'admin'
,
'auth'
,
'contenttypes'
,
'sessions'
,
'messages'
,
)
def
db_for_read
(
self
,
model
,
**
hints
):
if
model
.
_meta
.
app_label
in
self
.
default_apps
:
return
'default'
return
None
def
db_for_write
(
self
,
model
,
**
hints
):
if
model
.
_meta
.
app_label
in
self
.
default_apps
:
return
'default'
return
None
def
allow_relation
(
self
,
obj1
,
obj2
,
**
hints
):
if
obj1
.
_meta
.
app_label
in
self
.
default_apps
or
\
obj2
.
_meta
.
app_label
in
self
.
default_apps
:
return
True
return
None
def
allow_migrate
(
self
,
db
,
app_label
,
model_name
=
None
,
**
hints
):
if
app_label
in
self
.
default_apps
:
return
db
==
'default'
return
None
\ No newline at end of file
esi/esi/settings.py
View file @
395b8217
...
...
@@ -37,6 +37,8 @@ INSTALLED_APPS = [
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'webapp.apps.WebappConfig'
,
]
MIDDLEWARE
=
[
...
...
@@ -88,6 +90,8 @@ DATABASES = {
}
}
DATABASE_ROUTERS
=
[
'webapp.router.WebappDatabaseRouter'
,
'esi.router.EsiDatabaseRouter'
]
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
...
...
esi/app/__init__.py
→
esi/
web
app/__init__.py
View file @
395b8217
File moved
esi/app/admin.py
→
esi/
web
app/admin.py
View file @
395b8217
File moved
esi/app/apps.py
→
esi/
web
app/apps.py
View file @
395b8217
from
django.apps
import
AppConfig
class
A
ppConfig
(
AppConfig
):
name
=
'app'
class
Weba
ppConfig
(
AppConfig
):
name
=
'
web
app'
esi/app/migrations/__init__.py
→
esi/
web
app/migrations/__init__.py
View file @
395b8217
File moved
esi/webapp/models/__init__.py
0 → 100644
View file @
395b8217
from
.wp
import
*
from
.news
import
News
\ No newline at end of file
esi/webapp/models/news.py
0 → 100644
View file @
395b8217
from
django.db
import
models
class
News
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
255
)
url
=
models
.
TextField
(
max_length
=
2083
)
description
=
models
.
TextField
()
media_id
=
models
.
IntegerField
()
type_id
=
models
.
IntegerField
()
region_id
=
models
.
IntegerField
()
post_id
=
models
.
BigIntegerField
()
publish_date
=
models
.
DateTimeField
()
record_date
=
models
.
DateTimeField
()
company_id
=
models
.
BigIntegerField
()
is_accepted
=
models
.
BooleanField
(
default
=
False
)
class
Meta
:
db_table
=
'wp_esi_news_accept'
esi/
app/models
.py
→
esi/
webapp/models/wp
.py
View file @
395b8217
...
...
@@ -443,7 +443,7 @@ class WpIclContentStatus(models.Model):
class
WpIclCoreStatus
(
models
.
Model
):
id
=
models
.
BigIntegerField
()
id
=
models
.
BigIntegerField
(
primary_key
=
True
)
rid
=
models
.
BigIntegerField
()
module
=
models
.
CharField
(
max_length
=
16
)
origin
=
models
.
CharField
(
max_length
=
64
)
...
...
@@ -456,7 +456,7 @@ class WpIclCoreStatus(models.Model):
class
WpIclFlags
(
models
.
Model
):
id
=
models
.
IntegerField
()
id
=
models
.
IntegerField
(
primary_key
=
True
)
lang_code
=
models
.
CharField
(
max_length
=
10
)
flag
=
models
.
CharField
(
max_length
=
32
)
from_template
=
models
.
IntegerField
()
...
...
@@ -467,7 +467,7 @@ class WpIclFlags(models.Model):
class
WpIclLanguages
(
models
.
Model
):
id
=
models
.
IntegerField
()
id
=
models
.
IntegerField
(
primary_key
=
True
)
code
=
models
.
CharField
(
max_length
=
7
)
english_name
=
models
.
CharField
(
max_length
=
128
)
major
=
models
.
IntegerField
()
...
...
@@ -482,7 +482,7 @@ class WpIclLanguages(models.Model):
class
WpIclLanguagesTranslations
(
models
.
Model
):
id
=
models
.
IntegerField
()
id
=
models
.
IntegerField
(
primary_key
=
True
)
language_code
=
models
.
CharField
(
max_length
=
7
)
display_language_code
=
models
.
CharField
(
max_length
=
7
)
name
=
models
.
CharField
(
max_length
=
255
)
...
...
@@ -502,7 +502,7 @@ class WpIclLocaleMap(models.Model):
class
WpIclMessageStatus
(
models
.
Model
):
id
=
models
.
BigIntegerField
()
id
=
models
.
BigIntegerField
(
primary_key
=
True
)
rid
=
models
.
BigIntegerField
()
object_id
=
models
.
BigIntegerField
()
from_language
=
models
.
CharField
(
max_length
=
10
)
...
...
@@ -528,7 +528,7 @@ class WpIclNode(models.Model):
class
WpIclReminders
(
models
.
Model
):
id
=
models
.
BigIntegerField
()
id
=
models
.
BigIntegerField
(
primary_key
=
True
)
message
=
models
.
TextField
()
url
=
models
.
TextField
()
can_delete
=
models
.
IntegerField
()
...
...
@@ -540,7 +540,7 @@ class WpIclReminders(models.Model):
class
WpIclStringPositions
(
models
.
Model
):
id
=
models
.
BigIntegerField
()
id
=
models
.
BigIntegerField
(
primary_key
=
True
)
string_id
=
models
.
BigIntegerField
()
kind
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
position_in_page
=
models
.
CharField
(
max_length
=
255
)
...
...
@@ -551,7 +551,7 @@ class WpIclStringPositions(models.Model):
class
WpIclStringStatus
(
models
.
Model
):
id
=
models
.
BigIntegerField
()
id
=
models
.
BigIntegerField
(
primary_key
=
True
)
rid
=
models
.
BigIntegerField
()
string_translation_id
=
models
.
BigIntegerField
()
timestamp
=
models
.
DateTimeField
()
...
...
@@ -563,7 +563,7 @@ class WpIclStringStatus(models.Model):
class
WpIclStringTranslations
(
models
.
Model
):
id
=
models
.
BigIntegerField
()
id
=
models
.
BigIntegerField
(
primary_key
=
True
)
string_id
=
models
.
BigIntegerField
()
language
=
models
.
CharField
(
max_length
=
10
)
status
=
models
.
IntegerField
()
...
...
@@ -579,7 +579,7 @@ class WpIclStringTranslations(models.Model):
class
WpIclStrings
(
models
.
Model
):
id
=
models
.
BigIntegerField
()
id
=
models
.
BigIntegerField
(
primary_key
=
True
)
language
=
models
.
CharField
(
max_length
=
7
)
context
=
models
.
CharField
(
max_length
=
160
)
name
=
models
.
CharField
(
max_length
=
160
)
...
...
@@ -627,7 +627,7 @@ class WpIclTranslateJob(models.Model):
class
WpIclTranslationBatches
(
models
.
Model
):
id
=
models
.
IntegerField
()
id
=
models
.
IntegerField
(
primary_key
=
True
)
batch_name
=
models
.
TextField
()
tp_id
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
ts_url
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
...
...
@@ -865,7 +865,7 @@ class WpUsers(models.Model):
class
WpWpdatacharts
(
models
.
Model
):
id
=
models
.
AutoField
(
unique
=
True
)
id
=
models
.
AutoField
(
primary_key
=
True
)
wpdatatable_id
=
models
.
IntegerField
()
title
=
models
.
CharField
(
max_length
=
255
)
engine
=
models
.
CharField
(
max_length
=
10
)
...
...
@@ -878,7 +878,7 @@ class WpWpdatacharts(models.Model):
class
WpWpdatatables
(
models
.
Model
):
id
=
models
.
AutoField
(
unique
=
True
)
id
=
models
.
AutoField
(
primary_key
=
True
)
title
=
models
.
CharField
(
max_length
=
255
)
show_title
=
models
.
IntegerField
()
table_type
=
models
.
CharField
(
max_length
=
55
)
...
...
@@ -916,7 +916,7 @@ class WpWpdatatables(models.Model):
class
WpWpdatatablesColumns
(
models
.
Model
):
id
=
models
.
AutoField
(
unique
=
True
)
id
=
models
.
AutoField
(
primary_key
=
True
)
table_id
=
models
.
IntegerField
()
orig_header
=
models
.
CharField
(
max_length
=
255
)
display_header
=
models
.
CharField
(
max_length
=
255
)
...
...
esi/webapp/router.py
0 → 100644
View file @
395b8217
class
WebappDatabaseRouter
:
def
db_for_read
(
self
,
model
,
**
hints
):
if
model
.
_meta
.
app_label
==
'webapp'
:
return
'esi'
return
None
def
db_for_write
(
self
,
model
,
**
hints
):
if
model
.
_meta
.
app_label
==
'webapp'
:
return
'esi'
return
None
def
allow_relation
(
self
,
obj1
,
obj2
,
**
hints
):
if
obj1
.
_meta
.
app_label
==
'webapp'
or
\
obj2
.
_meta
.
app_label
==
'webapp'
:
return
True
return
None
def
allow_migrate
(
self
,
db
,
app_label
,
model_name
=
None
,
**
hints
):
if
app_label
==
'webapp'
:
return
db
==
'esi'
return
None
\ No newline at end of file
esi/app/tests.py
→
esi/
web
app/tests.py
View file @
395b8217
File moved
esi/app/views.py
→
esi/
web
app/views.py
View file @
395b8217
File moved
exa/exa/helpers/db.py
View file @
395b8217
...
...
@@ -15,6 +15,10 @@ class Database:
self
.
db
=
MySQLdb
.
connect
(
self
.
host
,
self
.
user
,
self
.
pwd
,
self
.
database
)
self
.
db
.
autocommit
(
True
)
self
.
cursor
=
self
.
db
.
cursor
()
self
.
db
.
set_character_set
(
'utf8'
)
self
.
cursor
.
execute
(
'SET NAMES utf8;'
)
self
.
cursor
.
execute
(
'SET CHARACTER SET utf8;'
)
self
.
cursor
.
execute
(
'SET character_set_connection=utf8;'
)
def
__del__
(
self
):
self
.
db
.
close
()
...
...
exa/exa/pipelines.py
View file @
395b8217
...
...
@@ -25,12 +25,12 @@ class ExaPipeline(object):
print
(
item
)
item
[
'description'
]
=
''
.
join
(
item
[
'description'
])
.
replace
(
'
\n
'
,
' '
)
data
=
(
item
[
'title'
],
item
[
'description'
],
item
[
'url'
],
item
[
'media_id'
],
item
[
'type_id'
],
item
[
'region_id'
],
item
[
'post_id'
],
item
[
'date'
],
datetime
.
now
()
.
date
(),)
query
=
"""INSERT INTO wp_esi_news
(title, description, URL, media_id, type_id, region_id, post_id, publish_date, record_date)
VALUES(
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);
\n
"""
item
[
'region_id'
],
item
[
'post_id'
],
item
[
'date'
],
datetime
.
now
()
.
date
(),
item
[
'company_id'
],
0
)
query
=
"""INSERT INTO wp_esi_news
_accept (title, description, URL, media_id, type_id, region_id, post_id,
publish_date, record_date, company_id, is_accepted) VALUES(
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);
\n
"""
print
(
item
)
news
=
self
.
db
.
insert
(
query
,
data
)
self
.
_insert_news_entiry
(
news
,
item
[
'company_id'
])
#
self._insert_news_entiry(news, item['company_id'])
# self.out.write(query)
return
item
...
...
exa/exa/spiders/mobihealthnews.py
View file @
395b8217
...
...
@@ -9,7 +9,7 @@ from ..items import ExaItem
db_settings
=
get_project_settings
()
.
get
(
'DB'
)
db
=
Database
(
**
db_settings
)
comp
=
db
.
select
(
"SELECT id, name, country FROM wp_esi_entity WHERE id
< 300
;"
)
comp
=
db
.
select
(
"SELECT id, name, country FROM wp_esi_entity WHERE id
= 3
;"
)
class
MobiHealthNewsSpider
(
scrapy
.
Spider
):
...
...
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