Pyreportjasper在尝试将时间戳作为参数传递给jrxm时出错

2024-05-18 05:36:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图将时间戳(字符串格式)作为参数传递给jasper studio使用pyreportjasper 1.0.2生成的jrxml文件。我的代码

import os
from platform import python_version
from pyreportjasper import JasperPy


def advanced_example_using_database():

 input_file ='/home/superusr/JaspersoftWorkspace/MyReports/sample9.jrxml'
 output = os.path.dirname(os.path.abspath(__file__)) + '/output/examples'

 con = {
     'driver': 'mysql',
     'username': 'root',
     'password': 'qwerty',
     'host': '127.0.0.1',
     'database': 'test_database',
     'schema': 'test_table',
     'port': '3306'
 }

 print("Running Jasper process!")    
 jasper = JasperPy()
 jasper.process(
 input_file,
    output_file=output,
     format_list=["pdf", "rtf"],
     parameters={"P1": "2016-04-01 00:02:00",'P2': "2016-04-01 03:02:00"},

     db_connection=con,
     locale='en_US'  
 )
advanced_example_using_database()

错误

Running Jasper process!
Parameter 'P2' of type 'java.sql.Timestamp with value '2016-04-01 03:02:00' is not supported by JasperStarter!
Traceback (most recent call last):
  File "run.py", line 42, in <module>
    advanced_example_using_database()
  File "run.py", line 40, in advanced_example_using_database
    locale='en_US'  
  File "/home/superusr/.local/lib/python2.7/site-packages/pyreportjasper/jasperpy.py", line 151, in process
    return self.execute()
  File "/home/superusr/.local/lib/python2.7/site-packages/pyreportjasper/jasperpy.py", line 190, in execute
    output = subprocess.check_call(self.command, shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '/home/superusr/.local/lib/python2.7/site-packa
ges/pyreportjasper/jasperstarter/bin/jasperstarter --locale en_US process "/home/super
usr/JaspersoftWorkspace/MyReports/sample9.jrxml" -o "/home/superusr/output/examples"
 -f pdf rtf -P  P2="2016-04-01 03:02:00"   P1="2016-04-01 00:02:00"   -t mysql -u root
 -p qwerty -H 127.0.0.1 -n test_database --db-port 3306' returned non-zero exit status 1

请建议任何适当的方法来传递参数


Tags: inpyhomeoutputexampleliblineprocess