I've a ".jrxml" file created by TIBCO Jaspersoft. I follow this link https://pypi.org/project/pyreportjasper/ to convert from ".jrxml" to ".pdf" by using Python . It seems work just fine when I was not using a database.
I did "Compiling" and "Processing" topic and it works just fine, but I stuck on a topic named "Advanced example - using a database". The code is below.
from platform import python_version
import pyreportjasper
def advanced_example_using_database():
input_file = 'C:/Users/CPM-USER/JaspersoftWorkspace/SCPS_TEST/test1.jrxml'
output = 'C:/Users/CPM-USER/Desktop'
con = {
'driver': 'mysql',
'username': 'root',
'password': 'root',
'host': 'localhost',
'database': 'icontrol_cscs_prj',
'port': '3306'
}
print(python_version())
jasper = pyreportjasper.JasperPy()
jasper.process(
input_file,
output_file=output,
format_list=["pdf"],
# parameters={'python_version': '3.7.4'},
db_connection=con,
locale='en_US' # LOCALE Ex.:(en_US, de_GE)
)
advanced_example_using_database()
It cause an error "Unable to load driver: com.mysql.jdbc.Driver".
The error indicates that you do not have the mysql driver in java classpath.
You need first to download the driver http://dev.mysql.com/downloads/connector/j/
Then according to pyreportsjasper documentation you need to place the .jar in the
directory.