This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
mssql-cli sources are located on GitHub (https://github.com/dbcli/mssql-cli). In order to contribute to the project, you are expected to:
- Have a GitHub account. For Microsoft contributors, follow the guidelines on https://opensourcehub.microsoft.com/ to create, configure and link your account
- Clone or fork the https://github.com/dbcli/mssql-cli repository into your private GitHub account
- Create pull requests against the https://github.com/dbcli/mssql-cli repository to get your code changes merged into the project repository.
-
Install latest Python from http://python.org. Please note that the version of Python that comes preinstalled on macOS is 2.7. It is recommended to install both Python 2.7 and supported versions of Python 3 (3.8 at the time of this writing) to ensure backwards compatibility for testing.
- The latest Python installation package can be downloaded from here.
- During installation, select the 'Add Python to PATH' option. Python must be in the PATH environment variable.
-
Clone the repo from https://github.com/dbcli/mssql-cli
When developing on a Python project, it is recommended to do so in a virtual environment. A virtual environment is a sandbox that maintains a copy of all libraries necessary to run python in a isolated environment without interfering with the system or global python. For more information on virtual environments, go to Virtual Environment Info.
If not developing in a virtual environment, please proceed to Install All Dependencies
Create a virtual environment in a subdirectory of your <workspaceRoot>
(<workspaceRoot>/env
, for example). Open command prompt or bash.
set PYLOC=<python3_location>
set PATH=%PYLOC%\Scripts;%PYLOC%;%PATH%
set PYTHONPATH=<workspaceRoot>
python -m venv <workspaceRoot>\env
set PYLOC=<python2_location>
set PATH=%PYLOC%\Scripts;%PYLOC%;%PATH%
set PYTHONPATH=<workspaceRoot>
python -m pip install --upgrade pip
python -m pip install --upgrade virtualenv
python -m virtualenv <workspaceRoot>\env
export PYTHONPATH=<workspaceRoot>
python3 -m venv <workspaceRoot>/env
export PYTHONPATH=<workspaceRoot>
python -m venv <workspaceRoot>/env
export PYTHONPATH=<workspaceRoot>
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-venv
python3 -m venv <workspaceRoot>/env
export PYTHONPATH=<workspaceRoot>
sudo apt-get update
sudo apt-get install python-pip
python -m pip install --upgrade pip
python -m pip install virtualenv
python -m virtualenv <workspaceRoot>/env
<workspaceRoot>\env\scripts\activate.bat
source <workspaceRoot>/env/bin/activate
deactivate
General development steps that apply to both a virtual environment or a global environment. If working in a virtual environment, do ensure the virtual environment is activated as the first command line of each following script.
<workspaceRoot>\env\scripts\activate.bat
set PYTHONPATH=<workspaceRoot>
cd <workspaceRoot>
python -m pip install --upgrade pip
python dev_setup.py
python build.py build
. <workspaceRoot>/env/bin/activate
export PYTHONPATH=<workspaceRoot>
cd <workspaceRoot>
python3 -m pip install --upgrade pip
python3 dev_setup.py
python3 build.py build
. <workspaceRoot>/env/bin/activate
export PYTHONPATH=<workspaceRoot>
cd <workspaceRoot>
python -m pip install --upgrade pip
python dev_setup.py
python build.py build
<workspaceRoot>\env\scripts\activate.bat
set PYTHONPATH=<workspaceRoot>
cd <workspaceRoot>
mssql-cli -S <hostname> -d <database> -U <username>
. <workspaceRoot>/env/bin/activate
export PYTHONPATH=<workspaceRoot>
cd <workspaceRoot>
./mssql-cli -S <hostname> -d <database> -U <username>
<workspaceRoot>\env\scripts\activate.bat
set PYTHONPATH=<workspaceRoot>
set MSSQL_CLI_SERVER=<hostname>
set MSSQL_CLI_DATABASE=<database>
set MSSQL_CLI_USER=<username>
set MSSQL_CLI_PASSWORD=<password>
set PYTHONIOENCODING=UTF-8
cd <workspaceRoot>
python build.py unit_test
python build.py integration_test
. <workspaceRoot>/env/bin/activate
export PYTHONPATH=<workspaceRoot>
export MSSQL_CLI_SERVER=<hostname>
export MSSQL_CLI_DATABASE=<database>
export MSSQL_CLI_USER=<username>
export MSSQL_CLI_PASSWORD=<password>
export PYTHONIOENCODING=UTF-8
cd <workspaceRoot>
python3 build.py unit_test
python3 build.py integration_test
. <workspaceRoot>/env/bin/activate
export PYTHONPATH=<workspaceRoot>
export MSSQL_CLI_SERVER=<hostname>
export MSSQL_CLI_DATABASE=<database>
export MSSQL_CLI_USER=<username>
export MSSQL_CLI_PASSWORD=<password>
export PYTHONIOENCODING=UTF-8
cd <workspaceRoot>
python build.py unit_test
python build.py integration_test
- Install Visual Studio Code
- Install the the VS Code Python extension
Open the workspace folder with VS Code. The python extension is not active yet as in the screenshot.
In order to activate the python extension, select one of the *.py
file in the explorer on the left.
You will see the extension becomes active and showes current version of python hooked up to the extension by default.
Create a file named <workspaceRoot>/.env
with contents:
MSSQL_CLI_SERVER=<hostname>
MSSQL_CLI_DATABASE=<database>
MSSQL_CLI_USER=<username>
MSSQL_CLI_PASSWORD=<password>
PYTHONIOENCODING=UTF-8
Select Python: Launch mssql-cli
and click the green arrow in order to launch mssql-cli debugger.
Debugger will run successfully as shown below.
Click Run Tests
on the bottom of VSCode, and select Discover Tests
among the test menu.
You can see all the discovered unit tests after discover process finishes. A test or a group of tests can be executed by one-click in VSCode as shown below.
Run unit tests as shown below.
Clicking Debug Test
will start debugger for a corresponding unit test as shown below.