1. Ben Antwi
  2. Valentina Reports ADK
  3. Вторник, Апрель 12 2022, 04:18 PM
  4.  Подписаться через email
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
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
Hello Ben,

Does this report work in Valentina Studio and problem only with python?
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
In Valentina Studio it works fine with just producing a record using a parameter for that row.
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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])
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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])

Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
@ Sergey Pashkov Please do you understand my logic?
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
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’)
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
This is original table I have below in the image
Вложения
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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)
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
The result from the test Tab is as the image below
Вложения
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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 ?
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
In Python?
You use setParameterValue to set an actual value:

report = project.report(...
report.setParameterValue( 'pitem_id','4' )
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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' )
?
Вложения
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
Yes, that's correct.
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
what if I want to get say last record in my table , please what Default Value should I use?
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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?
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
For example, you can execute sql query with max function to get the last ID if they are sequential
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
Ok, that's great!
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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?
Комментарий
There are no comments made yet.
Sergey Pashkov Ответ принят
Store the necessary value in a variable and pass it

report.setParameterValue( 'pitem_id', paramValue )
Комментарий
There are no comments made yet.
Ben Antwi Ответ принят
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 )
Вложения
Комментарий
There are no comments made yet.
  • Страница :
  • 1
  • 2
  • 3
  • 4
  • 5


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

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories