# Printing label based on dataset

**URL:** <https://forum.inductiveautomation.com/t/printing-label-based-on-dataset/85296>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [February 6, 2024, 2:02pm UTC](https://forum.inductiveautomation.com/t/printing-label-based-on-dataset/85296 "2024-02-06T14:02:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawel.kondol1](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@pawel.kondol1](https://forum.inductiveautomation.com/u/pawel.kondol1)\
**Post date:** [February 6, 2024, 2:02pm UTC](https://forum.inductiveautomation.com/t/printing-label-based-on-dataset/85296/1 "2024-02-06T14:02:38Z")

</div>

Hello

I like to print a label using script. I have label setup in Vision as container. This label contains 2 dynamic values. I am getting the values from the database and then I have a script to print an individual label per database row.

```auto
#Select query
pyData = system.db.runQuery ("SELECT * FROM [Ignition].[dbo].[Visitors_Conference]")

#printing parameters
def printout():
    job = system.print.createPrintJob(event.source.parent.getComponent('Container'))
    job.setShowPrintDialog(0)
    job.setPageHeight(3.93701)
    job.setPageWidth(2.44094)
    job.setMargins(.1)
    #job.setZoomFactor(0.9)
    job.setOrientation(0)
    job.print()

#Go through all rows in dataset
for row in pyData:
    
    Name = row["Name"]
    Grouping = row["Grouping"]
    
#update sample field for print out
    event.source.parent.getComponent('Container').getComponent('lbl_Name').text = Name

#Print the label
    system.util.invokeLater(printout, 2000)

```

The problem is that it only print the last row. For example, I have a simple table with 4 rows and some data. I want to print let's say names on the label. So it should print 4 labels with each row name, but instead it's printing just the Last row (Name 4) on all of them.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/e/befa75c18526f1c55aa9445de4b2d2c66c58d5b2.png)
