You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 the PyReportJasper.config() method:
driver: the correct value for the PostgreSQL database is postgres; you can find the values in the pyreportjasper/db.py -> DB.get_connection() method (the dbtype string in the "if" chain)
jdbc_driver: it's the full path up to and including the jdbc directory provided with the pyreportjasper library; the easiest way to find it in your case is the following python script:
import sys
import pathlib
from pyreportjasper import PyReportJasper # <-- you probably have this line in yout code
print(str(pathlib.Path(sys.modules[PyReportJasper.__module__].__file__).parent / "libs" / "jdbc"))
jdbc_dir: the correct value for the PostgreSQL database is org.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:
# The value of the JDBC_DIR variable is the path you found with the previous python script
JDBC_DIR=/venv/py3.8.18/lib/python3.8/site-packages/pyreportjasper/libs/jdbc
basename $(strings ${JDBC_DIR}/postgresql.jar | grep -P 'Driver.class$' | sed 's#/#.#g') .class
Note the schema key is mandatory, but meaningless for PostgreSQL; set it to the very same value you are using for the database key.
Finally a recap:
self._jasper_db_parameters=JasperDBParameters(
jdbc_driver='org.postgresql.Driver',
jdbc_dir='/venv/py3.8.18/lib/python3.8/site-packages/pyreportjasper/libs/jdbc',
driver='postgres',
host='....',
port='....',
username='....',
password='....',
schema='....', # <-- same value you used for the database parameter
database='....')
The text was updated successfully, but these errors were encountered:
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.
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:
The text was updated successfully, but these errors were encountered: