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

Adding load-sql.sh #93

Merged
merged 2 commits into from
Jul 22, 2019
Merged

Conversation

ScarlettZ98
Copy link
Contributor

Adding load-sql.sh in docker-scripts to make importing .sql files easier.
The shell scipt allows inputting data into a new database by
./docker-scripts/load-sql.sh SQL_FILE --dbname DBNAME

@tracyhenry
Copy link
Owner

This is awesome, thanks! I tested and it worked perfectly.

If you don't mind, can you help update the instructions here: https://github.com/tracyhenry/Kyrix/blob/master/compiler/examples/README.md

Then I'll go ahead and merge.

@tracyhenry
Copy link
Owner

hey I just found out that I can modify it myself. Merging.

@tracyhenry tracyhenry merged commit 9abe30e into tracyhenry:master Jul 22, 2019
docker cp $SQL_FILE kyrix_db_1:/$SQL_FILE

# import sql file content into the selected database
docker exec -it kyrix_db_1 /bin/sh -c "psql postgresql://postgres:kyrixftw@localhost/${DB_NAME} < ${SQL_FILE}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi hardcoded password... instead pull from the environment, and if needed make this the default...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script assumes local environment. It feels bad if we run setup-kyrix-var in user's local environment. I'm thinking this password thing should be in the config file (of course, need to fix #64 first), so that every script that needs it can read from it.

esac
done

echo 'DB_NAME='$DB_NAME
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: for consistency with the code below: echo "DBNAME=${DB_NAME}"

# create table and drop table
docker exec -it kyrix_db_1 psql postgresql://postgres:kyrixftw@localhost/postgres -c "CREATE DATABASE ${DB_NAME}";

# copy file to kyrix_db_1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth a comment... on most host OSs you can pipe directly to docker exec... except that (I think) win32 this might be weird... dunno about late-model versions of win32 and powershell... also nice to have the .sql file around when debugging inside the VM...

@ScarlettZ98 ScarlettZ98 deleted the adding_load-sql branch July 22, 2019 22:06
ericazhou7 pushed a commit to ericazhou7/Kyrix that referenced this pull request Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants