1. Ben Antwi
  2. Valentina Reports ADK
  3. Tuesday, April 12 2022, 04:18 PM
  4.  Subscribe via 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
Comment
There are no comments made yet.
Sergey Pashkov Accepted Answer
What version do you use? What changed since the time when it worked? Was anything updated?

"The specified module could not be found."
Maybe the Valentina extension can't be loaded due to not finding the VComponents library.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 61
Ben Antwi Accepted Answer
I have located and copied the valentina.pyd extension file to my working directory but I'm having same error message.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 62
Sergey Pashkov Accepted Answer
It is installed to C:\Users\USERNAME\Documents\Paradigma Software\VPython_x64_12
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 63
Ben Antwi Accepted Answer
@Sergey Pashkov I added query='SELECT... to the sql statement and error previous error is not showing anymore. I'm now getting this new error message

Traceback (most recent call last):
File "C:/Users/RAZOR64/Desktop/EC-PROJECT/report.py", line 8, in <module>
import valentina
ImportError: DLL load failed while importing valentina: The specified module could not be found.
I remember I had this error the very first time and I copied valentina.pyd from the examples folder to my working directory. This time I cannot see the valentina.pyd extension in the examples folder. Although I have the old valentina.pyd in working directory but it's not working for me.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 64
Sergey Pashkov Accepted Answer
Hi Ben,

Just add the parameter name:
query='SELECT...
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 65
Ben Antwi Accepted Answer
Hi,
@Sergey Pashkov I have tried several tried the line of code above but I still get error message saying

report = project.report(name='queryReport', dsn='sqlite://C:/User/RAZOR64/Desktop/EC-PROJECT/EmployeeDatabase.db','SELECT * FROM permanent_staff WHERE staff_no={}'.format(search_id))
^
SyntaxError: positional argument follows keyword argument
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 66
Sergey Pashkov Accepted Answer
So if I want to generate a particular record for a specific actor_id how I do that?

There are two ways:
1) Using parameters

The query in Valentina Studio is defined like that:
SELECT * FROM actor WHERE actor_id = $(pActorID)

Then, in Python code, we supply the actual value:

report.setParameterValue( 'pActorID', some_variable )


2) In the latest version - changing the source query:

project.report( 'Report_1', 'sqlite://....', 'SELECT * FROM actor WHERE actor_id={}'.format( some_variable ) )


As you can see you can set any query you want.

some_variable - is an ID that is passed somehow to the script.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 67
Ben Antwi Accepted Answer
And also after installing Valentina Pro 12 I cannot locate the example folder for python.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 68
Ben Antwi Accepted Answer
Hi Sergey Pashkov ,
Sorry for the late reply. So if I want to generate a particular record for a specific actor_id how I do that?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 69
Sergey Pashkov Accepted Answer
Hello Ben,

Do you have any further questions? Sorry, we didn't have an Internet connection for a while.

The latest version of VPython ADK contains a change for report generation - an ability to set any source query for a report:
project.report( 'Report_1', 'sqlite://....', 'SELECT * FROM actor ORDER BY actor_id DESC LIMIT 1' )


In the example, the report is generated for the latest record, without specifying an actual ID.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 70
Sergey Pashkov Accepted Answer
No need to change the default value in Valentina Studio , just set value in python.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 71
Ben Antwi Accepted Answer
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 )
Attachments (1)
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 72
Sergey Pashkov Accepted Answer
Store the necessary value in a variable and pass it

report.setParameterValue( 'pitem_id', paramValue )
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 73
Ben Antwi Accepted Answer
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?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 74
Ben Antwi Accepted Answer
Ok, that's great!
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 75
Sergey Pashkov Accepted Answer
For example, you can execute sql query with max function to get the last ID if they are sequential
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 76
Ben Antwi Accepted Answer
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?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 77
Ben Antwi Accepted Answer
what if I want to get say last record in my table , please what Default Value should I use?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 78
Sergey Pashkov Accepted Answer
Yes, that's correct.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 79
Ben Antwi Accepted Answer
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' )
?
Attachments (1)
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Reports ADK
  3. # 80


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