-
Notifications
You must be signed in to change notification settings - Fork 26
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
Conversation
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. |
hey I just found out that I can modify it myself. Merging. |
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}" |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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...
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