pgsqltoolsservice is a PostgreSQL implementation of the Data Management Protocol server. It is based on the Microsoft SQL Tools Service and pgAdmin.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Ensure that Python3.6 or above is installed - older versions of Python may work but are not supported
- Note that when these instructions refer to 'python3' or 'pip3' you may need to use the commands 'python' or 'pip' instead if you are on Windows
- Run
pip3 install -r requirements.txtfrom the root of the project- If you need to install pip, see pip Installation
We follow Python's PEP 8 style guide with a maximum line length of 160 characters. To ensure that your code has no style problems, run the following commands before committing (install them from pip first if needed):
- Run autopep8 to format your code according to PEP 8
autopep8 --in-place --aggressive --aggressive --max-line-length 160 -r .(from the project's root directory)
- Run flake8 to look for problems that need to be resolved manually
- On Mac/Linux:
./scripts/flake8.sh - On Windows:
.\scripts\flake8.ps1
- On Mac/Linux:
- Run
pip3 install -r requirements.txtif you haven't already nosetests(from the project's base directory)- To run with coverage:
nosetests --with-coverage --cover-package=pgsqltoolsservice,pgsmo --cover-htmlopen cover/index.html(to view coverage results)
- To run with coverage:
- Update your PYTHONPATH environment variable to contain the source directory. From within the project's main directory, run the following commands:
- On Mac/Linux:
export PYTHONPATH=$(pwd) - On Windows:
set PYTHONPATH=%cd%
- On Mac/Linux:
python3 pgsqltoolsservice/pgtoolsservice_main.py- Now you can pass in JSON RPC requests to stdin, following the language server protocol specifications.
It is possible to remotely attach a debugger to the PostgreSQL Tools Service through VS Code's Python extension. Just start the service with the command line argument --enable-remote-debugging and then, from the debug tab in VS Code, click 'Attach (Remote Debug)'.
If you want to debug startup, use the flag --enable-remote-debugging-wait instead, and the service will wait for you to attach the debugger before starting up.
By default, the remote debugging server runs on port 3000. If you need to use a different port, just pass it as the argument to that flag, e.g. --enable-remote-debugging=3001
You can set configuration options in Carbon to let you attach the remote debugger to the PostgreSQL Tools Service running inside Carbon. Set pgsql.useDebugSource to true and set pgsql.debugSourcePath to the path to the root of your PostgreSQL Tools Service repo (i.e. the folder containing this readme file). If you want to debug startup, also set pgsql.enableStartupDebugging to true. Here are examples from a settings.json file:
"pgsql.debugSourcePath": "/Users/mairvine/code/pgsqltoolsservice",
"pgsql.useDebugSource": true,
"pgsql.enableStartupDebugging": true
If you get "ptvsd module not found" error - ensure you have python 3 or above installed and user environment variable "path" pointing to latest python scripts. For eg. on a windows machine path value looks like "< path to current useraccount >\APPDATA\LOCAL\PROGRAMS\PYTHON\PYTHON36\SCRIPTS".
Content-Length: 106
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":4155,"capabilities":{},"trace":"off"}}Content-Length: 44
{"jsonrpc":"2.0","id":0,"method":"shutdown"}Content-Length: 40
{"jsonrpc":"2.0","id":0,"method":"exit"}
Content-Length: 106
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":4155,"capabilities":{},"trace":"off"}}Content-Length: 170
{"jsonrpc":"2.0","id":0,"method":"connection/connect","params":{"connectionstring":"dbname=postgres user=postgres password=password host=MAIRVINE-PC connect_timeout=10"}}Content-Length: 57
{"jsonrpc":"2.0","id":0,"method":"connection/disconnect"}Content-Length: 40
{"jsonrpc":"2.0","id":0,"method":"exit"}
To build an executable, run the following commands starting from the main source code directory on the platform you want to build for. The output will be placed in a folder called build.
- On Mac:
./scripts/build-mac.sh- The output will be placed in the build/pgtoolsservice directory
- On Linux:
./scripts/build-linux.sh - On Windows:
.\scripts\build.ps1- Or, from cmd.exe:
powershell.exe scripts\build.ps1
- Or, from cmd.exe: