Adds PostgreSQL support via new database driver user.postgresql. It follows
the same weedb interface used by SQLite and MySQL, including transaction and
schema helpers.
At this point, it should be considered a "beta" version.
- Python 3.7 or later.
- WeeWX 5.3 or later. Note that as of 08-Feb-2026, this version has not been
released yet, so you will have to run out of the branch
developmentin the WeeWX repository. See the WeeWX documentation on running from a git repository for more information. - PostgreSQL to which you have admin privileges. Tested on PostgreSQL v16.
psycopgv3. This is the client library for PostgreSQL.
Using psql, create a user for WeeWX. The username and password can be whatever
you like. You will also need to give permission for the user to create
databases.
In this example, we login using the client tool psql, then create a user named
weewx with the password weewx. We then allow the user to create databases.
# This is how you typically log in as the superuser postgres. Details may differ
# on your system.
sudo -u postgres psql
CREATE USER weewx WITH PASSWORD 'weewx';
ALTER USER weewx CREATEDB;Activate your WeeWX virtual environment, then install
the psycopg (v3) package.
source ~/weewx-venv/bin/activate
pip install psycopg
Now install the extension itself:
weectl extension install https://github.com/tkeffer/weewx-postgresql/archive/refs/heads/master.zipTake a look at your weewx.conf file. In particular, sections [Databases] and
[DataTypes]. Make sure they reflect the choices you made above.
The WeeWX schemas use type REAL for floating point values. Under MySQL and
SQLite, this resolves to an 8-byte floating point value, but under
PostgreSQL, it resolves to a 4-byte floating point value. Setting this option
to true will cause WeeWX to use DOUBLE PRECISION instead, which will be
8-byte values.
The previous steps added the capability to use the PostgreSQL driver.
Now you must tell WeeWX to actually use it. Look inside your weewx.conf for
the [DataBindings] section, then the [[wx_binding]] subsection. Edit the
database option to archive_postgresql. When you're done, the section should
look something like this:
[DataBindings]
...
[[wx_binding]]
# The database must match one of the sections in [Databases].
# This is likely to be the only option you would want to change.
database = archive_postgresql
...