PostgreSQL Compatibility for ERPNext: Meet frappe_pg

If you’re running Frappe/ERPNext—or any application built on Frappe—with a PostgreSQL database and frequently encountering this error:

Server Error

psycopg2.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction blockPossible source of error: erpnext (app)

You can easily resolve it using frappe_pg:
:backhand_index_pointing_right: https://github.com/excel-azmin/frappe_pg

This Frappe app provides comprehensive PostgreSQL compatibility patches, allowing ERPNext to run smoothly on PostgreSQL instead of MariaDB/MySQL.

Give it a try and share your feedback!
If you find any issues, feel free to open an issue on the repository—we’ll be happy to help.

2 Likes

Thanks Shaid for this app. I am going to test it also with PostgreSQL, Aurora PostgreSQL, AlloyDB and CockroachDB.

What would be the community effort needed to make PostgreSQL support a part of framework natively instead of this monkey patching app?

1 Like

@vgk Thank you very much, have you checkout the apps.

If PostgreSQL support a part of framework natively here is my findings:

  • Clean abstraction layer supporting multiple backends
  • Frappe’s database layer is heavily MySQL/MariaDB-centric
  • SQL Dialect Translation Replace MySQL-specific syntax:

LIMIT syntax differences
Auto-increment vs SERIAL/IDENTITY
Date/time functions (NOW() vs CURRENT_TIMESTAMP)
String concatenation (CONCATvs||)
IFNULLvsCOALESCE
Full-text search (MyISAM vs PostgreSQL’s tsvector)
JSON operations (different syntax)

  • Schema Management
    Modify frappe/core/doctype/doctype/doctype.py to generate PostgreSQL DDL
    Update frappe.db.add_column(), frappe.db.add_index(), etc.
    Handle constraint creation differences
    Sequence management for naming series