# How to build a database connection inside dashboard-template-node

**URL:** <https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, database\
**Created:** [26 September 2022 11:53 UTC](https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234 "2022-09-26T11:53:37Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![JustinB](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/justinb/32/68068_2.png) [@JustinB](https://discourse.nodered.org/u/JustinB)\
**Post date:** [28 September 2022 13:18 UTC](https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234/21 "2022-09-28T13:18:56Z")

</div>

I think the last\_page represents the last number you can click in the table. If I set last\_page to 15 I can navigate up to 15.

So as you said earlier

> [@bakman2](#):
>
> last page would be `total records/limit`

I have to get the total rows from the database, do the calculation and write it to last\_page

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [28 September 2022 13:38 UTC](https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234/22 "2022-09-28T13:38:42Z")

</div>

you can chain the nodes, first do a query like `select count(*) from yourtable`, and use a change node to set to some `total` property and use that for calculations and from there create the new query

---

<div class="post-metadata">

**Author:** ![JustinB](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/justinb/32/68068_2.png) [@JustinB](https://discourse.nodered.org/u/JustinB)\
**Post date:** [28 September 2022 14:03 UTC](https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234/23 "2022-09-28T14:03:11Z")

</div>

It's finally working. Thanks for all your effort! (And very sorry for the little dispute)

A little summary for everybody who is interested:

The flow

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f1589d94eb2c0e830846884f8348bc2569cdebd2.png)

Every node from left to right (except database):

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/7/a7895c68a498c3cc810a9243e23ee5ffb71e018f.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f076f1efb1fb468d66272d725822fb4653eac5c6.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f4014b16e94dcbb9f84fd3a4d37270c0e3810f3.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/4/e4e97d1a9240b2f12afea5aa4f86811c76b2ff6d.png)

And the code of the table(inside template node):

```auto
<script type="text/javascript" src="/tabulator-tables/dist/js/tabulator.min.js"></script>
<link rel="stylesheet" href="/tabulator-tables/dist/css/tabulator_semanticui.min.css" />
<div id="table-messungen"></div>
<script>
    var tableM = new Tabulator("#table-messungen", {
        height:"1000px",
        placeholder:"Keine Daten verfügbar!",
        layout:"fitColumns",
        pagination:true,
        paginationMode:"remote",
        //groupBy:"Zeitstempel",
        //groupToggleElement:"header",
        ajaxURL:"http://10.207.48.36:1880/fetchmessungen",
        paginationSize:1000,
    /*
        initialSort:[
            {column:"Zeitstempel", dir:"asc"},
        ],
    */
        columns:[
            {title:"Register", field:"Register", width:150},
            {title:"Druck (Pascal)", field:"Druck"},
            {title:"Zeitstempel", field:"Zeitstempel"},
        ],
       
    });
</script>

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [28 September 2022 14:11 UTC](https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234/24 "2022-09-28T14:11:50Z")

</div>

Nice 😄

Now just for a hint, you can now also create your own webpage, by adding a normal template node (non-UI) with the html/javascript/css code -\> response node and then opening the url in a new tab 🙂

I use this setup a lot to create custom API interfaces / pages.

---

<div class="post-metadata">

**Author:** ![JustinB](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/justinb/32/68068_2.png) [@JustinB](https://discourse.nodered.org/u/JustinB)\
**Post date:** [28 September 2022 14:21 UTC](https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234/25 "2022-09-28T14:21:41Z")

</div>

Thats cool! Thanks a lot!

You were right, your solution was the better one 😉

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 October 2022 14:21 UTC](https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234/26 "2022-10-12T14:21:54Z")

</div>

Closed on 12 October 2022 14:21 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/how-to-build-a-database-connection-inside-dashboard-template-node/68234.md?page=1)
