Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LB-503: Add command to connect to Timescale DB via develop.sh #767

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions develop.sh
@@ -1,4 +1,6 @@
#!/bin/bash
POSTGRES_ADMIN_LB_URI="postgresql://postgres@db/listenbrainz"
SQLALCHEMY_TIMESCALE_URI="postgresql://timescale_lb:timescale_lb@timescale/timescale_lb"

if [[ ! -d "docker" ]]; then
echo "This script must be run from the top level directory of the listenbrainz-server source."
Expand All @@ -19,8 +21,12 @@ function invoke_manage {

function open_psql_shell {
invoke_docker_compose run --rm web psql \
-U listenbrainz \
-h db listenbrainz
$POSTGRES_ADMIN_LB_URI
}

function open_timescale_shell {
invoke_docker_compose run --rm web psql \
$SQLALCHEMY_TIMESCALE_URI
}

function npm_install {
Expand All @@ -41,6 +47,11 @@ elif [ "$1" == "psql" ]; then
open_psql_shell
exit

elif [ "$1" == "timescale" ]; then
echo "Entering into PSQL shell to query Timescale DB..."
open_timescale_shell
exit

elif [ "$1" == "npm" ]; then
echo "Installing node dependencies..."
npm_install
Expand Down
2 changes: 1 addition & 1 deletion listenbrainz/webserver/__init__.py
Expand Up @@ -101,7 +101,7 @@ def gen_app(config_path=None, debug=None):
create_redis(app)

# Influx connection
create_influx(app)
# create_influx(app)

# RabbitMQ connection
try:
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Expand Up @@ -185,7 +185,7 @@ def init_db(force, create_db):
if not res:
raise Exception('Failed to drop existing database and user! Exit code: %i' % res)

if create_db:
if create_db or force:
print('Creating user and a database...')
res = ts.run_sql_script_without_transaction(os.path.join(TIMESCALE_SQL_DIR, 'create_db.sql'))
if not res:
Expand Down