Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
metadata-and-data
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
web-et-numerique-internet
data.grandlyon.com
web-portal
components
indexers
metadata-and-data
Commits
e770c5ba
Commit
e770c5ba
authored
6 years ago
by
Alessandro Cerioni
Browse files
Options
Downloads
Patches
Plain Diff
Making code robust w/ respect to non-existing tables.
parent
0759c0ef
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
3-doc-enricher.py
+8
-9
8 additions, 9 deletions
3-doc-enricher.py
with
8 additions
and
9 deletions
3-doc-enricher.py
+
8
−
9
View file @
e770c5ba
...
@@ -8,26 +8,24 @@ from utils.exit_gracefully import exit_gracefully
...
@@ -8,26 +8,24 @@ from utils.exit_gracefully import exit_gracefully
from
utils.my_logging
import
logging
from
utils.my_logging
import
logging
from
utils.postgis_helper
import
Remote
from
utils.postgis_helper
import
Remote
from
utils.serializers
import
encode_datetime
from
utils.serializers
import
encode_datetime
from
sqlalchemy.exc
import
NoSuchTableError
def
get_entries_from_postgis
(
link
,
cfg
,
no_features_per_page
=
1000
):
def
get_entries_from_postgis
(
link
,
cfg
,
no_features_per_page
=
1000
):
#print('here', link)
dbname
=
link
[
'
url
'
].
split
(
'
/
'
)[
-
1
]
dbname
=
link
[
'
url
'
].
split
(
'
/
'
)[
-
1
]
schema
,
table
=
link
[
'
name
'
].
split
(
'
.
'
)
schema
,
table_name
=
link
[
'
name
'
].
split
(
'
.
'
)
print
(
dbname
,
schema
,
table
)
#print(cfg)
#exit(1)
logging
.
info
(
'
Getting data from database %s...
'
%
dbname
)
logging
.
info
(
'
Getting data from database %s...
'
%
dbname
)
logging
.
info
(
'
Establishing a database connection...
'
)
logging
.
info
(
'
Establishing a database connection...
'
)
pg
=
Remote
(
hostname
=
cfg
[
'
host
'
],
dbname
=
dbname
,
username
=
cfg
[
'
username
'
],
password
=
cfg
[
'
password
'
])
pg
=
Remote
(
hostname
=
cfg
[
'
host
'
],
dbname
=
dbname
,
username
=
cfg
[
'
username
'
],
password
=
cfg
[
'
password
'
])
logging
.
info
(
'
Done.
'
)
logging
.
info
(
'
Done.
'
)
table
=
pg
.
get_table
(
table
,
schema
=
schema
)
try
:
table
=
pg
.
get_table
(
table_name
,
schema
=
schema
)
except
NoSuchTableError
:
#print(pg.get_tables('bruit'))
logging
.
debug
(
'
Table %s in schema % s not found :-(
'
%
(
table_name
,
schema
))
return
count
=
pg
.
count_entries
(
table
)
count
=
pg
.
count_entries
(
table
)
...
@@ -313,6 +311,7 @@ if __name__ == '__main__':
...
@@ -313,6 +311,7 @@ if __name__ == '__main__':
with
open
(
"
config.yaml
"
,
'
r
'
)
as
yamlfile
:
with
open
(
"
config.yaml
"
,
'
r
'
)
as
yamlfile
:
cfg
=
yaml
.
load
(
yamlfile
)
cfg
=
yaml
.
load
(
yamlfile
)
main
(
cfg
)
while
True
:
while
True
:
try
:
try
:
main
(
cfg
)
main
(
cfg
)
...
...
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