Skip to content

Commit 74e199b

Browse files
committed
Use SUPERSET_DBUSER and SUPERSET_DBPASS to access superset-db
1 parent c63a53e commit 74e199b

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ services:
104104
# - ADMIN_LASTNAME=user
105105
# - ADMIN_EMAIL=admin@fab.org
106106
# - ADMIN_PASSWORD=admin
107+
- SUPERSET_DBUSER=superset
108+
- SUPERSET_DBPASS=superset
107109
superset-db:
108110
build: superset-db
109111
container_name: superset-db

superset/create-data-sources.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ def main():
2525
headers=headers
2626
)
2727
headers['X-CSRFToken'] = r.json()['result']
28+
29+
db_user = os.getenv('SUPERSET_DBUSER', 'postgres')
30+
db_pass = os.getenv('SUPERSET_DBPASS', '')
31+
base_uri = f'postgresql://{db_user}:{db_pass}@superset-db:5432'
32+
2833
r = s.post(
2934
'http://localhost:8088/api/v1/database',
3035
headers=headers,
3136
json={
3237
'database_name': 'Learning Locker',
33-
'sqlalchemy_uri': 'postgresql://postgres@superset-db:5432/learninglocker'
38+
'sqlalchemy_uri': f'{base_uri}/learninglocker'
3439
}
3540
)
3641
print(r.json())
@@ -40,7 +45,7 @@ def main():
4045
headers=headers,
4146
json={
4247
'database_name': 'OpenLRW',
43-
'sqlalchemy_uri': 'postgresql://postgres@superset-db:5432/openlrw'
48+
'sqlalchemy_uri': f'{base_uri}/openlrw'
4449
}
4550
)
4651
print(r.json())
@@ -50,7 +55,7 @@ def main():
5055
headers=headers,
5156
json={
5257
'database_name': 'Jupyter',
53-
'sqlalchemy_uri': 'postgresql://postgres@superset-db:5432/jupyter'
58+
'sqlalchemy_uri': f'{base_uri}/jupyter'
5459
}
5560
)
5661
print(r.json())

superset/superset_config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
# superset metadata (slices, connections, tables, dashboards, ...).
2121
# Note that the connection information to connect to the datasources
2222
# you want to explore are managed directly in the web UI
23-
SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://postgres@superset-db:5432/superset'
23+
SUPERSET_DBUSER = os.getenv('SUPERSET_DBUSER', 'postgres')
24+
SUPERSET_DBPASS = os.getenv('SUPERSET_DBPASS', '')
25+
SQLALCHEMY_DATABASE_URI = (
26+
'postgresql+psycopg2://'
27+
f'{SUPERSET_DBUSER}:{SUPERSET_DBPASS}'
28+
'@superset-db:5432/superset'
29+
)
2430

2531
# Flask-WTF flag for CSRF
2632
WTF_CSRF_ENABLED = True

0 commit comments

Comments
 (0)