1. Ben Antwi
  2. Valentina Reports ADK
  3. Dienstag, April 12 2022, 04:18 PM
  4.  Abonnieren via E-Mail
Valentina is a great reporting tool but I'm still finding it difficult to search a record from sqlite database with python. Please I need help
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Hello Ben,

Does this report work in Valentina Studio and problem only with python?
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
In Valentina Studio it works fine with just producing a record using a parameter for that row.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
I want to run the sql query example below to enable the user to type in any item_ID the user want , so that sql statement will return the exact record of the item_Id typed by the user.


SELECT item_Id, FROM permanent_staff WHERE staff_no=? ''',([Search_Id])
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
I want to run the sql query example below to enable the user to type in any item_ID the user want , so that sql statement will return the exact record of the item_Id typed by the user.


SELECT item_Id, FROM items WHERE item_Id=? ''',([Search_Id])

Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
@ Sergey Pashkov Please do you understand my logic?
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
So you defined a parameter and used it in a query that you created in the Valentina Studio.

We have added a method to set report’s parameters in python:
report.setParameterValue( ‘param1’, ‘value1’)
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
This is original table I have below in the image
Anhänge
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
I have set parameter in patameter Tab as pitem_id and Default Value =4.

This is the query in the Valentina Studio:


SELECT item_id, item_name, item_type from items WHERE item_id=$P(pitem_id)
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
The result from the test Tab is as the image below
Anhänge
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
I don't want to change my parameter and Default Value all the time when I want to retrieve a record from the table. Please is there a way to set the parameter and Default Value one time to get all records when an input field requires a record ?
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
In Python?
You use setParameterValue to set an actual value:

report = project.report(...
report.setParameterValue( 'pitem_id','4' )
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
I want to use a search field like the image below to search in my application , so is it possible to use

report.setParameterValue( 'pitem_id','4' )
?
Anhänge
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Yes, that's correct.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
what if I want to get say last record in my table , please what Default Value should I use?
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Assuming I don't know the length of item_id column and I want to get the last item_id in the items table, Please what parameter should I set?
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
For example, you can execute sql query with max function to get the last ID if they are sequential
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Ok, that's great!
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Sorry I'm still confused, If a specific parameter Value for example

report.setParameterValue( 'pitem_id','4' )
is set. Meaning after I package the app as .exe I can only search for the record with parameter value of '4'. But I would like to search for any other record. So is there a say a variable that could hold all the parameter values one time?
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Store the necessary value in a variable and pass it

report.setParameterValue( 'pitem_id', paramValue )
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Ok , so can I set the parameter name and parameter value in Valentina Studio Pro as in the image below right?





and pass same parameter Value variable name in python as follows?


report.setParameterValue( 'pitem_id', paramValue )
Anhänge
Kommentar
There are no comments made yet.
  • Seite :
  • 1
  • 2


There are no replies made for this post yet.
However, you are not allowed to reply to this post.