quant
quant

Reputation: 4482

How to run a bash script through pycharm?

I have the following set of bash commands

docker pull mcr.microsoft.com/mssql/server:2017-latest
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=my_password' \
   --name 'sql1' -p 1401:1433 \
   -v "my_space":/opt/project \
   -d mcr.microsoft.com/mssql/server:2017-latest

winpty docker exec -it sql1 bash
mkdir -p /var/opt/mssql/backup
cp my_db /var/opt/mssql/backup/

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "my_password" -i /opt/project/scripts/database_import/sql_script.sql

apt-get update -y
apt-get install python3-pip -y

python3 -m pip install pymssql
python3 -m pip install pandas==0.19.2
python3 -m pip install time
python3 -m pip install sqlalchemy
python3 -m pip install sqlalchemy_utils
cd /opt/project/
python3 scripts/database_import/import_database.py

What this set of commands is essentially doing is that it pulls the mssql server, restores a database, installs some python packages and it runs a python script inside the mssql docker container.

Is there a way to run this bash script, from pycharm ?

Upvotes: 0

Views: 412

Answers (1)

Sergey K.
Sergey K.

Reputation: 2013

Sure thing. If you are using the latest version, then Shell Script should be available https://www.jetbrains.com/help/idea/shell-scripts.html So, for example, I have test.sh file: enter image description here

I can just click this green run button and PyCharm will run it, or create Run Configuration for it (see the link above).

Upvotes: 3

Related Questions