PJBS for Python

Post Reply
User avatar

Topic author
arne_v
Senior Member
Posts: 637
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

PJBS for Python

Post by arne_v » Sun Jan 19, 2025 2:58 pm

(also posted to comp.os.vms/INFO-VAX - hope people don't mind)

There is a PJBS open source project at:
https://sourceforge.net/projects/pjbs/
which has been forked at:
https://github.com/JCotton1123/php-jdbc-bridge

It allows PHP applications to access a database using a
JDBC driver.

It works like:

PHP app with PJBridge class-->proxy process with JDBC driver-->database

PJBridge.php is very simple so it was easy to convert to Python:

Python app with PJBridge class-->proxy process with JDBC driver-->database

And I even created a DB API 2.0 layer on top of it to be more Pythonesque:

Python app with PJBS and PJBridge classes-->proxy process with JDBC driver-->database

And it seems to work reasonable well.

There are a few things to be aware:
* data are always returned as string so numeric data need to be
manual converted.
* no support for database transaction
* I have not tested error handling or performance
* very limited functional testing so lot of stuff may be missing
(feel free to add it!)

This tool is not particular interesting on common platforms like
Linux and Windows as both PHP and Python has drivers for almost
all databases available there.

But it is a bit more interesting on VMS as a driver for VMS
is not a top priority for most language projects and
database vendors. But the database vendors usually
provide a type 4 JDBC driver. A type 4 JDBC driver is a pure
Java JDBC driver, which means that you can copy the jar file
from Linux/Windows to VMS and it works.

So with:

portable PHP/Python API-->portable Java proxy-->portable type 4 JDBC driver

it all works even if the language project and the database vendor has
not even heard about VMS!

And this is not just theory. I have tested with:
- MySQL
- PostgreSQL
- Oracle DB - thin
- IBM DB2
- MS SQLServer
- SQLite (*)
- Derby
- H2
- HSQLDB

And previously I have tested PJBS with:
- Rdb - native (*)
- Rdb - thin
- Mimer

*) Type 2 not type 4 so VMS version required!

I would group them in:
* PHP/Python drivers available (or will be available) on VMS: MySQL, PostgreSQL, SQLite
* not interesting for PHP/Python developers (they will prefer SQLIte): Derby, H2, HSQLDB
* potential relevance of PJBS: Oracle DB, IBM DB2, MS SQLServer

If anyone want to play with it then it is available at:
https://www.vajhoej.dk/arne/vmsstuff/pjbs/
Arne
arne@vajhoej.dk
VMS user since 1986

Post Reply