Open massimiliano-della-rovere opened 9 months ago
The jdbc_dir
you only need to inform in the case of PostgreSQL if you want to use a different version than the one already included with the library. In that case, you provide the path where you placed your PostgreSQL JDBC .jar file that you want to use. Otherwise, the library automatically adds the path of the JDBC that comes with it. See here.
The name of the PostgreSQL JDBC driver is easily found in its documentation. See here.
So here is a simple example of usage:
pyreportjasper = PyReportJasper()
pyreportjasper.config(
input_file,
output_file,
output_formats=["pdf"],
db_connection={
'driver': 'postgres',
'jdbc_driver': 'org.postgresql.Driver',
'username': '....',
'password': '....',
'host': '....',
'database': '....',
'port': '5434',
},
)
And yes, we do need to update and enrich our documentation with more information and examples. We appreciate any help you can provide.
The documentation on how to connect to a DB is COMPLETELY wrong. »This document is written and tested for pyreportjasper version 2.1.3«
Here is how I did with a bit of explanation: you need 3 different keys in the
db_connection
dict required by thePyReportJasper.config()
method:driver
: the correct value for the PostgreSQL database ispostgres
; you can find the values in the pyreportjasper/db.py -> DB.get_connection() method (thedbtype
string in the "if
" chain)jdbc_driver
: it's the full path up to and including thejdbc
directory provided with the pyreportjasper library; the easiest way to find it in your case is the following python script:jdbc_dir
: the correct value for the PostgreSQL database isorg.postgresql.Driver
; this was the trickiest value to find out, I used the following BASh script, that can be useful if you want to use the other undocumented jdbc drivers:Note the
schema
key is mandatory, but meaningless for PostgreSQL; set it to the very same value you are using for thedatabase
key.Finally a recap: