With the release of PostgresML 2.0, this documentation has been deprecated. New installation instructions are available.
A PostgresML deployment consists of two different runtimes. The foundational runtime is a Python extension for Postgres (pgml-extension) that facilitates the machine learning lifecycle inside the database.
Additionally, we provide a dashboard (pgml-dashboard) that can connect to your Postgres server and provide additional management functionality. It will also provide visibility into the models you build and data they use.
Install PostgreSQL with PL/Python
PostgresML leverages Python libraries for their machine learning capabilities. You'll need to make sure the PostgreSQL installation has PL/Python built in.
We recommend you use Postgres.app because it comes with PL/Python. Otherwise, you'll need to install PL/Python manually. Once you have Postgres.app running, you'll need to install the Python framework. Mac OS has multiple distributions of Python, namely one from Brew and one from the Python community (Python.org); Postgres.app and PL/Python depend on the community one. The following versions of Python and Postgres.app are compatible:
|PostgreSQL version||Python version||Download link|
|14||3.9||Python 3.9 64-bit|
|13||3.8||Python 3.8 64-bit|
All Python.org installers for Mac OS are available here. You can also get more details about this in the Postgres.app documentation.
Each Ubuntu/Debian distribution comes with its own version of PostgreSQL, the simplest way is to install it from Aptitude:
$ sudo apt-get install -y postgresql-plpython3-12 python3 python3-pip postgresql-12
EnterpriseDB provides Windows builds of PostgreSQL available for download.
Install the extension
To use our Python package inside PostgreSQL, we need to install it into the global Python package space. Depending on which version of Python you installed in the previous step, use the corresponding pip executable.
--database-url option to point to your PostgreSQL server.
sudo pip3 install pgml-extension python3 -m pgml_extension --database-url=postgres://user_name:password@localhost:5432/database_name
If everything works, you should be able to run this successfully:
psql -c 'SELECT pgml.version()' postgres://user_name:password@localhost:5432/database_name
Run the dashboard
The PostgresML dashboard is a Django app, that can be run against any PostgreSQL installation. There is an included Dockerfile if you wish to run it as a container, or you may want to setup a Python venv to isolate the dependencies. Basic install can be achieved with:
- Clone the repo:
git clone https://github.com/postgresml/postgresml && cd postgresml/pgml-dashboard
- Set your
echo PGML_DATABASE_URL=postgres://user_name:password@localhost:5432/database_name > .env
- Install dependencies:
pip install -r requirements.txt
- Run the server:
python manage.py runserver
Join our Discord and ask us anything! We're friendly and would love to talk about PostgresML.
Try It Out
Try PostresML using our free managed cloud. It comes with 5 GiB of space and plenty of datasets to get you started.