Code Monkey home page Code Monkey logo

pyreportjasper's People

Contributors

artofhuman avatar aulla avatar dependabot[bot] avatar jadsonbr avatar kvkamaltej avatar tobecwb avatar winkelband avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyreportjasper's Issues

Missing required option when using CSV file as datasource

Hello,

I'd like to use CSV file as datasource to produce a XLSX output file.
I'm using the following syntax:

jasper = JasperPy()
    jasper.process(
        jasper_file,
        output_file=output_file,
        format_list=['xlsx'],
        db_connection={
            'data_file': 'mytest.csv',
            'driver': 'csv'
        },
        locale=jasper_locale,
        resource=jasper_folder)

However I'm stuck with the following error:
jasperstarter: error: argument --csv-columns is required

When running the jasperstarter command through the console adding the required --csv-columns option, it works.

Where could I add the --csv-columns option using the pyreportjasper library ?

Thanks for your help.

Julien

Connecting to wrong port

Hi/Ola, first thank you for the amazing lib.
so basically my problem is when I try to generate a report using the command below:
"C:\Users\IN_x32\Desktop\PescArt2.0 ToBuildSetUP\pyjasper\jasperstarter\bin\jasperstarter.exe" --locale pt_BR process "C:\Users\IN_x32\Desktop\PescArt2.0 ToBuildSetUP\ReportTemplates\Saidas_Provinica.jrxml" -o "C:\Data\FishTools\PescArte\Reports" -f pdf -t generic -u pes_admin -p root -H localhost -n pescarte --db-port 5454 --db-driver org.postgresql.Driver --db-url jdbc:postgresql://localhost/pescarte

I get the erro:
`GRAVE: Connection error:
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:265)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.(PgConnection.java:194)
at org.postgresql.Driver.makeConnection(Driver.java:450)
at org.postgresql.Driver.connect(Driver.java:252)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at de.cenote.jasperstarter.Db.getConnection(Db.java:140)
at de.cenote.jasperstarter.Report.fill(Report.java:252)
at de.cenote.jasperstarter.App.processReport(App.java:217)
at de.cenote.jasperstarter.App.main(App.java:102)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.postgresql.core.PGStream.(PGStream.java:68)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144)
... 10 more

Unable to connect to database: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.`

I think jasperstarter is connecting to the wrong port im using port 5454 on my project but is trying to connect to default postgres port 5432.

cStringIO is not available in python 3.x

Please consider updating import StringIO from io for Python 3.x since cStringIO is not longer available in Python 3.x

Traceback (most recent call last):
...
import pyjasper
File "C:\Program Files\Python36\lib\site-packages\pyjasper_init_.py", line 4, in
from pyjasper.client_subreport import JasperGeneratorWithSubreport
File "C:\Program Files\Python36\lib\site-packages\pyjasper\client.py", line 13, in
from cStringIO import StringIO
ModuleNotFoundError: No module named 'cStringIO'

Soln:-
use
from io import StringIO
instead of
from cStringIO import StringIO
for Python 3.x

Python3 compatibility

The exception handling in jasperpy.py is not compatible with Python3, where there is no "e.message". The line should perhaps be changed to look like this:

                logger.exception(str(e))

That would also be safe on Python2. I'd be happy to submit a PR if required?

Error filling reportError executing SQL statement for: test1.

I'm getting an error of Error filling reportError executing SQL statement for: test1. with the code below.
The required jar file is in the jdbc folder.
And my db credentials is correct.

# -*- coding: utf-8 -*-
import os
from platform import python_version
from pyreportjasper import JasperPy

def advanced_example_using_database():

    input_file = '~/JaspersoftWorkspace/MyReports/test1.jrxml'

    output = os.path.dirname(os.path.abspath(__file__)) # + '/output/examples'
    con = {
        'driver': 'generic',
        'username': 'username',
        'password': 'password',
        'jdbc_url': 'jdbc:sqlserver://localhost:1433;databaseName=testdb',
        'jdbc_driver': 'net.sourceforge.jtds.jdbc.Driver'

    }
    jasper = JasperPy()

    jasper.process(
        input_file,
        output_file=output,
        format_list=["pdf"], # format_list=["pdf", "rtf", "xml"],
        parameters={},
        db_connection=con,
        locale='en_US'  # LOCALE Ex.:(en_US, de_GE, pt_BR)
    )

advanced_example_using_database()

Chamada pelo Odoo

Saudações!
Estou tentando gerar o relatório através do Odoo, sistema operacional Windows10.
Apenas relatórios simples sem parâmetros ou conexão com banco de dados são impressos.
Testes mais elaborados apresentam erros em jasperpy.py:
logger.exception(str(e))
raise NameError('Your report has an error and couldn '
r''t be processed!\ Try to output the '
'command using the attribute command; '
'and run it manually in the console!')

Porém, executando-se o comando diretamente pelo prompt os arquivos são gerados.
Acredito que seja erro de permissão de criação/leitura de arquivos.

Obrigado.

can not pip install git+https://github.com/bcdev/jpy@master#egg=jpy

I can not install: pip install git+https://github.com/bcdev/jpy@master#egg=jpy

Enviroment:

Maven:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\archivos\Programacion\tools\apache-maven-3.6.3-bin\bin..
Java version: 1.8.0_261, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_261\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Microsoft Visual Studio 14.0:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

Error:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files\Java\jdk1.8.0_261\jre\bin\server" "/LIBPATH:C:\Program Files\Java\jdk1.8.0_261\lib" /LIBPATH:c:\archivos\programacion\virtualenvs\nemesis\env\libs /LIBPATH:C:\Users\jmarco\AppData\Local\Programs\Python\Python38-32\libs /LIBPATH:C:\Users\jmarco\AppData\Local\Programs\Python\Python38-32 /LIBPATH:c:\archivos\programacion\virtualenvs\nemesis\env\PCbuild\win32 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x86" jvm.lib /EXPORT:PyInit_jpy build\temp.win32-3.8\Release\src\main\c\jpy_module.obj build\temp.win32-3.8\Release\src\main\c\jpy_diag.obj build\temp.win32-3.8\Release\src\main\c\jpy_verboseexcept.obj build\temp.win32-3.8\Release\src\main\c\jpy_conv.obj build\temp.win32-3.8\Release\src\main\c\jpy_compat.obj build\temp.win32-3.8\Release\src\main\c\jpy_jtype.obj build\temp.win32-3.8\Release\src\main\c\jpy_jarray.obj build\temp.win32-3.8\Release\src\main\c\jpy_jobj.obj build\temp.win32-3.8\Release\src\main\c\jpy_jmethod.obj build\temp.win32-3.8\Release\src\main\c\jpy_jfield.obj build\temp.win32-3.8\Release\src\main\c\jni/org_jpy_PyLib.obj /OUT:build\lib.win32-3.8\jpy.cp38-win32.pyd /IMPLIB:build\temp.win32-3.8\Release\src\main\c\jpy.cp38-win32.lib
Creating library build\temp.win32-3.8\Release\src\main\c\jpy.cp38-win32.lib and object build\temp.win32-3.8\Release\src\main\c\jpy.cp38-win32.exp
jpy_module.obj : error LNK2001: unresolved external symbol __imp__JNI_CreateJavaVM@12
build\lib.win32-3.8\jpy.cp38-win32.pyd : fatal error LNK1120: 1 unresolved externals
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.exe' failed with exit status 1120

Thks

Jasperserver Commerial license

Dear all,

I have a commercial license of Jasperserver. I built a report in Jaspersoft Studio using the highcharts library and everything works within Jaspersoft Studio.

When I try to compile the compile the report using
jasper = JasperPy()
jasper.compile(input_file)
I get the following error:
Exception in thread "main" net.sf.jasperreports.engine.JRRuntimeException: Unknown entity http://jaspersoft.com/schema/highcharts.xsd, not loading.

To the best of my understanding, this is a license issue. Do you have any advice on how to solve the issue?

Thanks

Ivan

java.sql.Date Error

I'am try to execute my report and get this error:

Parameter 'P_FILTRO_FECHA' of type 'java.sql.Date with value '2019-01-16' is not
supported by JasperStarter!

Interferance with python logging

Hi, has anyone experience this python module interfering with python logging module? If I import "from pyreportjasper import JasperPy", my script's logging just refuses to output any logs.

jasper.process error

Hi, i'm trying to enjoy with your package, but i'm receiving this error:

File "jreport.py", line 13, in processing
jasper.process(input_file, output=output, format_list=["pdf", "rtf"])
TypeError: process() got an unexpected keyword argument 'output'

where
input_file is /home/gtraficante/JaspersoftWorkspace/MyReports/hello_world.jasper (it exists)
output is /home/gtraficante/JaspersoftWorkspace/MyReports/output (it exists)

this is the jreport.py content:

#sudo pip install pyreportjasper
import os
import pyjasper
from pyjasper import JasperPy

def processing(nomeFile):
    input_file = '/home/gtraficante/JaspersoftWorkspace/MyReports/'+nomeFile
    print(input_file)
    output = '/home/gtraficante/JaspersoftWorkspace/MyReports/output'
    print(output)
    jasper = pyjasper.JasperPy()
    print(jasper)
    jasper.process(input_file, output=output, format_list=["pdf", "rtf"])
    print('FINITO!')

def listing_parameters(nomeFile):
    input_file = '/home/gtraficante/JaspersoftWorkspace/MyReports/'+nomeFile
    jasper = pyjasper.JasperPy()
    output = jasper.list_parameters(input_file)
    print(output)
    

    
    
#processing('hello_world.jrxml')    
processing('hello_world.jasper')

Example in Flask

Create example using Flask and put the example in separate repository and put the link in readme

PDF font

When the library generate output, in rtf format all work fine, but in pdf format i can't have the same font, it seems to use only one type of font i don't know wich font

Cannot pip install

Complete output (6 lines):
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\xxx\AppData\Local\Temp\pip-install-cay4d0h_\jpy\setup.py", line 100, in
with open('README.rst') as file:
FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'
Building a 64-bit library for a Windows system
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Getting Null as values while running jasper report using pyreport jasper and mongo

Following is my python code to run a simple report that displays records in tabular format :
FYI I am using folllowing mongo driver : mongodb-driver-sync-3.7.1.jar

from pyreportjasper import JasperPy

if __name__ == '__main__':

  input_file = '/home/ubuntu1604/JaspersoftWorkspace/MyReports/my_Landscape.jasper'
    output = '/home/ubuntu1604'
    con = {
        'driver': 'none',
        'jdbc_driver': 'mongodb.jdbc.MongoDriver',
        'jdbc_url': 'jdbc:mongo://user:[email protected]:27107/db_name',
        'port': '27107'
    }
    jasper = JasperPy()
    jasper.process(
        input_file,
        output_file=output,
        format_list=["pdf"],
        parameters={"PARAM_1":"hawkeye", "PARAM_2":"xyz"},
        db_connection=con,
        locale='en_US')

If I am running the same report in Jasper Studio 6.6.0, I am getting aroung 34 rows of valid data. But when I run the above code I just get Null as values in one row.

What could be the issue?

Reports using subdatasets support

Good Evening, hope you be fine. The matter of this issue it's that I'm trying to generate a JSON file based report where I'm using a main dataset to filling the most of it and a subdataset to filling a pie chart in the same report. Main dataset and subdataset take their data from different array atributes in the same Json object, so what I'd like to ask you is: does the library supports working with subdataset enabled reports? If so, I'd really appreciate if you were able to post an example on how to do it. Attached to this issue there's an example of the Json structure I'm using as the report datasource:
Detalle_Costos.txt

Thanks in advance for your help

Regards:
Esteban

Error to Install

Hi, I'm trying install and got this error:

Using cached jpy-0.7.5.zip (144 kB)
ERROR: Command errored out with exit status 1:
command: /Users/rangeltorrezan/Desktop/KeepsDev/workspace/KeepsReports/.virtualenvs/report-keeps/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-ycwfl3f1/jpy/setup.py'"'"'; file='"'"'/private/tmp/pip-install-ycwfl3f1/jpy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-nzqyo9rs
cwd: /private/tmp/pip-install-ycwfl3f1/jpy/
Complete output (6 lines):
Building a 64-bit library for a Darwin system
Traceback (most recent call last):
File "", line 1, in
File "/private/tmp/pip-install-ycwfl3f1/jpy/setup.py", line 100, in
with open('README.rst') as file:
FileNotFoundError: [Errno 2] No such file or directory: 'README.rst'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I try install with pip instal, downloading the package and using setup install, with root, with user ... anyway ..

I'm using MacOS but I tried in other device with Ubuntu.

Does pyjasper support Mongodb

I am trying to connect Mongodb from pyjasper. But I couldn't find any example which using Mongodb here.

Is this library support Mongodb?

JSONQL data source support

I just filed a request with jasperstarter to add JSONQL data source support. Since I driver them through pyjasper, I'd like to request the same here. I believe the change is as simple as this:

$ diff -U5 t.t /usr/local/lib/python3.6/dist-packages/pyjasper/jasperpy.py
--- t.t 2018-05-22 19:46:03.381854873 +0100
+++ /usr/local/lib/python3.6/dist-packages/pyjasper/jasperpy.py 2018-05-22 19:41:23.923518239 +0100
@@ -137,10 +137,13 @@
                 command += ' --data-file ' + db_connection['data_file']
 
             if 'json_query' in db_connection:
                 command += ' --json-query ' + db_connection['json_query']
 
+            if 'jsonql_query' in db_connection:
+                command += ' --jsonql-query ' + db_connection['jsonql_query']
+
         self._command = command
 
         return self.execute()
 
     @staticmethod

The change could even, in principle, be added in parallel with the upstream change. If needed, I'd be happy to do a PR.

json_query

Hi, when i try to use json file, i receive this error:

jasperstarter: error: argument --json-query: expected one argument
Traceback (most recent call last):
File "jreport.py", line 97, in
processingJson('testJson.jrxml')
File "jreport.py", line 31, in processingJson
locale='en_US'
File "/usr/local/lib/python2.7/dist-packages/pyjasper/jasperpy.py", line 144, in process
return self.execute()
File "/usr/local/lib/python2.7/dist-packages/pyjasper/jasperpy.py", line 183, in execute
output = subprocess.check_call(self.command, shell=True)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '/usr/local/lib/python2.7/dist-packages/pyjasper/jasperstarter/bin/jasperstarter --locale en_US process "/home/gtraficante/JaspersoftWorkspace/MyReports/testJson.jrxml" -o "/home/gtraficante/JaspersoftWorkspace/MyReports/output" -f pdf rtf -t json --data-file /home/gtraficante/Dropbox/python/report/first.json --json-query ' returned non-zero exit status 1

Probably it depend form parameter json_query, i don't know how it should be setted.

    jasper.process(
         input_file,
         output_file=output,
         format_list=["pdf", "rtf"],
         db_connection={
            'data_file': data_file,
            'driver': 'json',
            'json_query': '',
         },
         locale='en_US'
    )

Failed to pass a directory as a parameter.

Hello, I was working on subreport and it failed to find the subreport when generating the PDF. I found a solution is to define the directory of the subreport as a parameter.

 <subreportExpression><![CDATA[$P{subReport} + 'subreport.jasper']]></subreportExpression>

It still failed at first attempt so I verify all my paths and parameters to see if they are all correct, directly from the command line. I found that it failed because the parameters are sent with quotation marks and I think it is not necessary to have. But I haven't tried other types of data like the timestamp mentioned in #57, just a suggestion from what I have encountered.

Example in Django

Create example using Django put the example in separate repository and put the link in readme

Virtualizer

When i try to generate large reports, i'm getting the error "gc overhead limit exceeded jasper reports".

I read something about virtualizer to generate large reports.

How do i use virtualizer with jasperstarter/pyreportjasper?

pyreportjasper or pyreport?

This repository name is pyreport the but name of the project is pyreportjasper.
Why not change the repository name to pyreportjasper?

Yes, I know.. pyreport it's very good name. But the pip repository already have the project pyreport (owned by GaelVaroquaux) last released Jul 14, 2009.

Or.. even better, the project name could be pyjasperstarter in view of it is just a wrapper for the jasperstarter

ValueError: not enough values to unpack (expected 3, got 1)

I got the following error when attempting to install pyreportjasper.

    ERROR: Command errored out with exit status 1:
     command: 'c:\users\lehrian\envs\cc\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\lehrian\\AppData\\Local\\Temp\\pip-install-_d6pjin2\\pyreportjasper\\setup.py'"'"'; __file__='"'"'C:\\Users\\lehrian\\AppData\\Local\\Temp\\pip-install-_d6pjin2\\pyreportjasper\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\lehrian\AppData\Local\Temp\pip-pip-egg-info-4nmol1bb'
         cwd: C:\Users\lehrian\AppData\Local\Temp\pip-install-_d6pjin2\pyreportjasper\
    Complete output (10 lines):
    openjdk version "15" 2020-09-15
    OpenJDK Runtime Environment (build 15+36-1562)
    OpenJDK 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\lehrian\AppData\Local\Temp\pip-install-_d6pjin2\pyreportjasper\setup.py", line 44, in <module>
        if check_java_version_1_8() is None:
      File "C:\Users\lehrian\AppData\Local\Temp\pip-install-_d6pjin2\pyreportjasper\setup.py", line 32, in check_java_version_1_8
        major, minor, _ = version_number.split('.')
    ValueError: not enough values to unpack (expected 3, got 1)
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

(CC) C:\Users\lehrian>javac -version
javac 15

The error is because I have Java OpenJDK 15 installed instead of the expected Oracle JDK 8. Does pyreportjasper only support Oracle JDK? It this simply the installation script or is there a dependence on Oracle proprietary additions to the Oracle JDK?

pyreports subreports support

Hi, hope you're fine. I'd like to ask you if there's pyreport support for Jaspereports subreports feature, and if yes, would you mind sending me an example of how to use it. Thanks in advance for your help.

Does it work for Python 3

Hello,

does it work on Python 3 ?
if it does, can you please let me know. as I tried but didn't work.

Thanks.

Impossible to set Locale to JSON_LOCALE

I have a big trouble when it comes to process JSON file, I could process nicely lots of different data in that JSON. But... when it comes to real numbers such as 3.123 my report represents that data as an Integer even thought I set the field settiog to a (Double, Float, BigDecimal...) all them interprets them as an Integer like 3123 ... Doing bit of research I figured out that when I pass the locale "es_ES" , in my case I need to format the report en spanish localization.
I realized that the JSON_LOCALE that is a parameter configuration related to the driver of the json adapter setted in the Jasper.process(...) method sets "es_ES" globally. The fact is that I really need to modify the JSON_LOCALE parameter to allow the report to interpret correctly the JSON floating numbers. Also, I should avoid to use "en_US" Locale globally, only set it at the JSON_LOCALE parameter.

I hope you can fix this Issue. I wouldd be very thanked.

Print Screen from Reports for Python, with JasperReports.

I found this code posted by Mr Jadsonbr, adapted to my needs, and it works.

I have the following questions.

  1. Can i see the report on screen before you burn it to disk.
  2. How to send parameters to the report, for example the invoice number, company code.

Tanks
Robert
Costa Rica

import sys
import os
import pyjasper
from platform import python_version
from pyjasper.jasperpy import JasperPy

#def advanced_example_using_database():
input_file = os.path.dirname(os.path.abspath(file)) + '/report4.jrxml'
output = os.path.dirname(os.path.abspath(file)) + '/reportes'
print(input_file)
print(output)

con = {
'driver': 'postgres',
'username': 'postgres',
'password': 'Administra8080',
'host': 'localhost',
'database': 'municipal',
'port':'5432'
}
jasper = JasperPy()
jasper.process(input_file,output_file=output,format_list=["pdf"],db_connection=con)

Pyreportjasper giving error when trying to pass timestamp as parameters to jrxml

I am trying to pass timestamp as a parameter to the jrxml file generated by the jasper studio , but i am getting the error as follows.

My code is as follows:
...Python Code
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()
...

The error generated is as follows:
...
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
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-packages/pyreportjasper/jasperstarter/bin/jasperstarter --locale en_US process "/home/superusr/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
...
please suggest any appropriate method to pass the parameters

Get data from resource file

I want to set a date format from .properties(resource file) file. How to do this in pyreportjasper ?
eg:(new SimpleDateFormat($R{format.date})).format(new Date())

Unable to load driver / Exception in thread "main"

Hi/Ola, first thank you for the time you are taking to answer my issue.
So was trying to use, jasperpy in the program im building so I followed your tutorial and I manage to build the hello world report.
So I wanted to try with my database(postgres), and I keep getting the following error :
Unable to load driver: org.postgresql.Driver
this is the processing function I used:
`def processing_DB():
input_file = os.path.dirname(os.path.abspath(file))+'/examples/saidas.jasper'
output = os.path.dirname(os.path.abspath(file)) + '/examples'
con={
'driver': 'postgres',
'username': 'postgres',
'password': 'postgres',
'host': 'local',
'database': 'DBToGo',
'schema': 'public',
'port': '5432'
}

jasper = jasperpy.JasperPy()
jasper.process(input_file= input_file, 
               output_file= output, 
               format_list= ["pdf","rtf"], 
               db_connection= con,
               locale='pt_BR'
               )
print("Done!")    `

and the error was still there, so I tried using command line:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyjasper/jasperstarter/bin/jasperstarter --locale pt_BR process "/Users/mruserpleasedontkillme/Documents/workspace/theProject/Reports/examples/saidas.jasper" -o "/Users/mruserpleasedontkillme/Documents/workspace/Teaching/Reports/examples" -f pdf rtf -t postgres -u postgres -p postgres -H local -n DBToGo --db-port 5432

and the error was still there, so I tried using different approaches so i tried:
/Users/mruserpleasedontkillme/Downloads/jasperstarter/bin/jasperstarter --locale pt_BR process "/Users/mruserpleasedontkillme/Documents/workspace/theProject/Reports/examples/saidas.jasper" -o "/Users/mruserpleasedontkillme/Documents/workspace/theProject/Reports/examples" -f pdf rtf -t generic --db-url jdbc:postgresql://localhost/DBToGo --db-driver org.postgresql.Driver -u postgres -p postgres -H local -n DBToGo --db-port 5432

and got a different erro this time:
Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:72) at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:62) at de.cenote.tools.classpath.ApplicationClasspath.addJars(ApplicationClasspath.java:127) at de.cenote.tools.classpath.ApplicationClasspath.addJarsRelative(ApplicationClasspath.java:142) at de.cenote.jasperstarter.App.processReport(App.java:169) at de.cenote.jasperstarter.App.main(App.java:102)

And again thanks for your time.

Invalid resource

i've updated the package, but it doesn't work:

/home/gtraficante/JaspersoftWorkspace/MyReports/Blank_Letter.jasper
True
True
/home/gtraficante/JaspersoftWorkspace/MyReports/output
True
<pyjasper.jasperpy.JasperPy instance at 0x7f6a27c87d40>
Traceback (most recent call last):
File "jreport.py", line 55, in
processing('Blank_Letter.jasper')
File "jreport.py", line 19, in processing
jasper.process(input_file, output_file=output, format_list=["pdf", "rtf"])
File "/usr/local/lib/python2.7/dist-packages/pyjasper/jasperpy.py", line 144, in process
return self.execute()
File "/usr/local/lib/python2.7/dist-packages/pyjasper/jasperpy.py", line 191, in execute
raise NameError('Invalid resource directory!')
NameError: Invalid resource directory!

the code is

import os
import pyjasper
from pyjasper import jasperpy

def processing(nomeFile):
    input_file = '/home/gtraficante/JaspersoftWorkspace/MyReports/'+nomeFile
    print(input_file)
    print(os.path.isdir('/home/gtraficante/JaspersoftWorkspace/MyReports'))
    print(os.path.isfile(input_file))
    output = '/home/gtraficante/JaspersoftWorkspace/MyReports/output'
    print(output)
    print(os.path.exists(output))    
    jasper = jasperpy.JasperPy()
    print(jasper)
    jasper.process(input_file, output_file=output, format_list=["pdf", "rtf"])
    print('The End!')

processing('Blank_Letter.jasper') 


with the old version you sended me yesterday (0.1.4) all works fine

Proposed fix to AttributeError: 'module' object has no attribute 'JasperPy'

Hi. Thanks for locking this together. I got stuck with a AttributeError: 'module' object has no attribute 'JasperPy' error and corrected it with using 'from pyjasper import jasperpy' and jasper = jasperpy.JasperPy() instead. Did you want to take a quick look if this is an improvement on your currently documented approach? Thanks again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.