SQL Reporting Workbench for FreeCAD

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
mario52
Posts: 2847
Joined: Wed May 16, 2012 2:13 pm

Re: SQL Reporting Workbench for FreeCAD

Postby mario52 » Fri Dec 27, 2019 10:32 am

hi
HolgerL wrote:
Fri Dec 06, 2019 8:01 am
- removed the mm and make the fields number
- filtered Length,Width,Height for 16mm entries, because these are the furniture plates. (40mm are the sidewalls..) and gave them a 4. filter attribute
- for all these furniture entries I simply calculated the volume and devided by 16 to get the total plate area. done
try also this macro, you split like you want Macro_FCTreeView Image but FreeCAD version 0.17 no yet upgraded

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
User avatar
dcapeletti
Posts: 430
Joined: Wed Jul 23, 2014 2:27 pm

Re: SQL Reporting Workbench for FreeCAD

Postby dcapeletti » Sun Feb 16, 2020 7:15 pm

furti wrote:
Sat Jan 12, 2019 11:02 am
Columns
Columns is a comma separated list of properties you want in the result for each object.

* is a special property that returns the whole object instead of a single property. This might be useful when you want to perform certain operations on some objects in python. You can select them with a select statement, and process them afterwards.

When you use a function (Sum, Min, Max, Count) here, only a single row will be returned with the function applied to each object. You can not mix single Properties and functions. But it should be possible to use multiple functions in a single select statement.
Hello, if I add a new property to the object called Provider, can I access it by means of an sql instruction? How can I do it?

Code: Select all

select Provider from document where Name = 'Box'
select Base_Provider from document where Name = 'Box'
None of the above instructions work.

Thanks
User avatar
furti
Posts: 338
Joined: Mon Nov 27, 2017 5:27 pm

Re: SQL Reporting Workbench for FreeCAD

Postby furti » Mon Feb 17, 2020 6:01 am

You mean the property is called "Provider"?
If so, the first query should work.

What is the problem with the query?
User avatar
dcapeletti
Posts: 430
Joined: Wed Jul 23, 2014 2:27 pm

Re: SQL Reporting Workbench for FreeCAD

Postby dcapeletti » Mon Feb 17, 2020 5:44 pm

furti wrote:
Mon Feb 17, 2020 6:01 am
You mean the property is called "Provider"?
If so, the first query should work.

What is the problem with the query?
It's a dynamic property that I add to the object myself.
Attached is a sample video https://www.youtube.com/watch?v=g3Bs_jz ... e=youtu.be

The first query does not throw an error but no result is shown, in the second query, the next error is thrown.

Code: Select all

ERROR:root:
Traceback (most recent call last):
  File "/home/dcapeletti/.FreeCAD/Mod/Reporting/report.py", line 352, in __init__
    self.statement = SQL_PARSER.parse(plainTextStatement)
  File "/home/dcapeletti/.FreeCAD/Mod/Reporting/sql/sql_parser.py", line 1149, in parse
    sqlStatement = sql_grammar.parse(sqlString, actions=ParserActions())
  File "/home/dcapeletti/.FreeCAD/Mod/Reporting/sql/sql_grammar.py", line 1958, in parse
    return parser.parse()
  File "/home/dcapeletti/.FreeCAD/Mod/Reporting/sql/sql_grammar.py", line 1942, in parse
    raise ParseError(format_error(self._input, self._failure, self._expected))
  File "<string>", line None
sql.sql_grammar.ParseError: Line 1: expected [a-zA-Z0-9\.], [ \t\r\n], [ \t\r\n], ","
Select Label, Base_Provider from document where Name = 'Box'
                  ^
But as shown in the spreadsheet, through Box.Base_Provider I can recover the data without any problem.

Greetings
User avatar
furti
Posts: 338
Joined: Mon Nov 27, 2017 5:27 pm

Re: SQL Reporting Workbench for FreeCAD

Postby furti » Tue Feb 18, 2020 9:07 am

Now I can see what is wrong here. The character _ is not allowed in Property names right now. I created a Issue for this. https://github.com/furti/FreeCAD-Reporting/issues/27

Is it possible that you rename the Property to something Alphanumeric like "BaseProvider" instead of "Base_Provider"?
User avatar
dcapeletti
Posts: 430
Joined: Wed Jul 23, 2014 2:27 pm

Re: SQL Reporting Workbench for FreeCAD

Postby dcapeletti » Tue Feb 18, 2020 12:39 pm

furti wrote:
Tue Feb 18, 2020 9:07 am
Now I can see what is wrong here. The character _ is not allowed in Property names right now. I created a Issue for this. https://github.com/furti/FreeCAD-Reporting/issues/27

Is it possible that you rename the Property to something Alphanumeric like "BaseProvider" instead of "Base_Provider"?
Hello, the query works correctly if I create the property but do not add it to any group, as shown in the image. That way if you can access it directly with Provider, but if I add it to a group, FreeCAD adds the group name separated by _.
Attachments
Group property.png
Group property.png (16.37 KiB) Viewed 224 times
User avatar
dcapeletti
Posts: 430
Joined: Wed Jul 23, 2014 2:27 pm

Re: SQL Reporting Workbench for FreeCAD

Postby dcapeletti » Wed Feb 19, 2020 9:01 pm

I think this project is very powerful when it comes to creating reports and not only that, but using object manipulation instructions via the freecad API using SQL directly. :)