# Sql utils for retrieving energyplus tabular data

**URL:** <https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505>\
**Category:** ladybug-tools\
**Tags:** energyplus, ladybug\
**Created:** [May 29, 2022, 1:13pm UTC](https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505 "2022-05-29T13:13:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![BorisPlotnikov](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/borisplotnikov/32/280_2.png) [@BorisPlotnikov](https://discourse.ladybug.tools/u/BorisPlotnikov)\
**Post date:** [May 29, 2022, 1:13pm UTC](https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505/1 "2022-05-29T13:13:14Z")

</div>

Hello!  
Not sure if this is the right place for this sort of comment so if it’s not I apologise.

I was working with ladybug’s python package in order to retrieve sql data from energy plus, namely with the tabular\_data\_by\_name function in the SQLiteResult class.

I came across a situation where the number of elements in a row of tabular\_data\_by\_name is larger than the number of columns in tabular\_column\_names. After some debugging I saw that there are situations where for the same table there are multiple ReportNames -

 ![image](https://discourse.ladybug.tools/uploads/default/original/3X/6/5/65c83ee9d19e0ba42939d978c6cd855d620e8bf3.png)

and wanted to propose an option to filter by report name as well, either extending the function or creating a new one.  
If this is something that you think might be useful i’d be happy to work on a pr for this.

thanks!  
Boris

---

<div class="post-metadata">

**Author:** ![TrevorFedyna](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/trevorfedyna/32/15628_2.png) [@TrevorFedyna](https://discourse.ladybug.tools/u/TrevorFedyna)\
**Post date:** [May 29, 2022, 3:20pm UTC](https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505/2 "2022-05-29T15:20:09Z")

</div>

I don’t know how to do from SQL tools; but I do interact with the HB SQLite files in ipynb via:  
[honeybee energy sdk:: Results](https://github.com/ladybug-tools/honeybee-energy/blob/master/honeybee_energy/simulation/output.py)  
[ladybug sdk: sql](https://github.com/ladybug-tools/ladybug/blob/master/ladybug/sql.py)

---

<div class="post-metadata">

**Author:** ![chris](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/chris/32/10179_2.png) [@chris](https://discourse.ladybug.tools/u/chris)\
**Post date:** [May 31, 2022, 6:43pm UTC](https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505/3 "2022-05-31T18:43:40Z")

</div>

Hey @BorisPlotnikov ,

Having a “ReportName” option on the method that retrieves the tabular data sounds useful and I would be happy to review a PR for [honeybee-energy](https://github.com/ladybug-tools/honeybee-energy) if you put it together. My only suggestion is that you give this new report\_name option a default value of `None` and simply let the method work as it did previously when no report\_name is specified. This way, nothing in the existing plugin will break.

---

<div class="post-metadata">

**Author:** ![BorisPlotnikov](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/borisplotnikov/32/280_2.png) [@BorisPlotnikov](https://discourse.ladybug.tools/u/BorisPlotnikov)\
**Post date:** [June 5, 2022, 12:37pm UTC](https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505/4 "2022-06-05T12:37:06Z")

</div>

thanks @TrevorFedyna, I’ll check the references.  
If I do see that adding a report name is useful for my use case,  
I was thinking of changing the interface of the function `tabular_data_by_name`

from:  
`def tabular_data_by_name(self, table_name, j_to_kwh=True):`

to:  
`def tabular_data_by_name(self, table_name, j_to_kwh=True, report_name=None):`

@chris, did I understand you correctly?

thanks!

---

<div class="post-metadata">

**Author:** ![chris](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/chris/32/10179_2.png) [@chris](https://discourse.ladybug.tools/u/chris)\
**Post date:** [June 6, 2022, 9:53pm UTC](https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505/5 "2022-06-06T21:53:44Z")

</div>

Yes, if you want to add that `report_name=None` argument and send a PR, I would be happy to review and merge it if it looks good.

---

<div class="post-metadata">

**Author:** ![BorisPlotnikov](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/borisplotnikov/32/280_2.png) [@BorisPlotnikov](https://discourse.ladybug.tools/u/BorisPlotnikov)\
**Post date:** [June 7, 2022, 2:36pm UTC](https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505/6 "2022-06-07T14:36:23Z")

</div>

great, thanks!  
here’s a pr, will appreciate any push backs 🙂

> <https://github.com/ladybug-tools/ladybug/pull/555/files>

---

<div class="post-metadata">

**Author:** ![chris](https://discourse.ladybug.tools/user_avatar/discourse.ladybug.tools/chris/32/10179_2.png) [@chris](https://discourse.ladybug.tools/u/chris)\
**Post date:** [June 7, 2022, 4:08pm UTC](https://discourse.ladybug.tools/t/sql-utils-for-retrieving-energyplus-tabular-data/18505/7 "2022-06-07T16:08:06Z")

</div>

Thank you for the PR, @BorisPlotnikov . It generally looks good but I see that the tests are failing due to a syntax error. If you can push another commit that fixes this case, I’ll happily merge it.
