Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
skais
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Sturgis
skais
Commits
1ba9dceb
Commit
1ba9dceb
authored
3 years ago
by
Raphael Sturgis
Browse files
Options
Downloads
Patches
Plain Diff
added get_db_connection in config
parent
f84815d3
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!12
version 0.2a
,
!10
Resolve "Image creation bugs with 0 size windows"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
skais/utils/config.py
+14
-1
14 additions, 1 deletion
skais/utils/config.py
with
14 additions
and
1 deletion
skais/utils/config.py
+
14
−
1
View file @
1ba9dceb
...
@@ -8,6 +8,8 @@ import os
...
@@ -8,6 +8,8 @@ import os
from
pathlib
import
Path
from
pathlib
import
Path
from
configparser
import
ConfigParser
from
configparser
import
ConfigParser
import
psycopg2
def
get_config_file
():
def
get_config_file
():
"""
"""
...
@@ -58,6 +60,7 @@ def get_data_path():
...
@@ -58,6 +60,7 @@ def get_data_path():
.
format
(
data_path
,
config_file
))
.
format
(
data_path
,
config_file
))
return
data_path
return
data_path
def
get_db_config
():
def
get_db_config
():
"""
"""
Read db config from user configuration file.
Read db config from user configuration file.
...
@@ -83,3 +86,13 @@ def get_db_config():
...
@@ -83,3 +86,13 @@ def get_db_config():
raise
Exception
(
'
Invalid data path: {}. Update configuration file {}
'
raise
Exception
(
'
Invalid data path: {}. Update configuration file {}
'
.
format
(
dict
,
config_file
))
.
format
(
dict
,
config_file
))
return
dict
return
dict
def
get_db_connection
():
db_config
=
get_db_config
()
connection
=
psycopg2
.
connect
(
user
=
db_config
[
'
user
'
],
password
=
db_config
[
'
password
'
],
host
=
db_config
[
'
host
'
],
port
=
db_config
[
'
port
'
],
database
=
db_config
[
'
database
'
])
return
connection
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