# Sqlite SELECT OK from terminal, empty result from NR

**URL:** <https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440>\
**Category:** General\
**Tags:** database\
**Created:** [20 December 2022 01:42 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440 "2022-12-20T01:42:26Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Petr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/petr/32/6413_2.png) [@Petr](https://discourse.nodered.org/u/Petr)\
**Post date:** [20 December 2022 01:42 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/1 "2022-12-20T01:42:26Z")

</div>

I have quite complex SQL query.  
From the terminal on the server everything is OK with the command  
`sqlite3 power.sqlite ".read sql.txt"` (my query is stored in the sql.txt file).

Unfortunatelly from the NR the result of the query is: `msg.payload : array[0] [empty]`

```auto
[
    {
        "id": "ce0dde258edf86ae",
        "type": "sqlite",
        "z": "3ec042cc2b88ead8",
        "mydb": "a33f828b.b04e2",
        "sqlquery": "msg.topic",
        "sql": "create index if not exists power_jd on power (julianday(timestamp), total_kwh); with pwr(timestamp, reading, ratetoprior) as ( select julianday(timestamp), total_kwh, (select(c.total_kwh - p.total_kwh) / (julianday(c.timestamp) - julianday(p.timestamp)) from power as p where julianday(p.timestamp) < julianday(c.timestamp) order by julianday(p.timestamp) desc limit 1) from power as c order by julianday(timestamp) ), periods(timestamp) as ( select julianday(strftime('%Y-%m-%d %H', (min(timestamp)), '-1 month') || ':00:00.000') from pwr union all select julianday(datetime(timestamp, '+1 month')) from periods where timestamp < (select max(timestamp) from pwr) ), readings(timestamp, reading) as ( select timestamp, (select reading - (b.timestamp - p.timestamp) * ratetoprior from pwr as b where b.timestamp >= p.timestamp limit 1) as reading from periods as p where timestamp between(select min(timestamp) from pwr) and(select max(timestamp) from pwr) ), used(timestamp, kwh) as ( select timestamp, reading - lag(reading) over() from readings ) select strftime('%m.%Y', timestamp) as \"mm-yyy\", cast(kwh as int) as \"kwh\" from used where kwh is not null",
        "name": "",
        "x": 580,
        "y": 1140,
        "wires": [
            [
                "f0ee7a20a2b3b935"
            ]
        ]
    },
    {
        "id": "247626382557a383",
        "type": "function",
        "z": "3ec042cc2b88ead8",
        "name": "function 4",
        "func": "msg.topic = String.raw`create index if not exists power_jd on power (julianday(timestamp), total_kwh);\n\nwith pwr(timestamp, reading, ratetoprior) as\n(\n select julianday(timestamp),\n total_kwh,\n (select(c.total_kwh - p.total_kwh) / (julianday(c.timestamp) - julianday(p.timestamp))\n from power as p\n where julianday(p.timestamp) < julianday(c.timestamp)\n order by julianday(p.timestamp) desc\n limit 1)\n from power as c\n order by julianday(timestamp)\n ),\nperiods(timestamp) as\n (\n select julianday(strftime('%Y-%m-%d %H', (min(timestamp)), '-1 month') || ':00:00.000')\n from pwr\n union all\n select julianday(datetime(timestamp, '+1 month'))\n from periods\n where timestamp < (select max(timestamp) from pwr)\n ),\nreadings(timestamp, reading) as\n (\n select timestamp,\n (select reading - (b.timestamp - p.timestamp) * ratetoprior\n from pwr as b\n where b.timestamp >= p.timestamp\n limit 1) as reading\n from periods as p\n where timestamp between(select min(timestamp) from pwr)\nand(select max(timestamp) from pwr)\n ),\nused(timestamp, kwh) as\n (\n select timestamp,\n reading - lag(reading) over()\n from readings\n )\n select strftime('%m.%Y', timestamp) as \"mm-yyy\",\n cast(kwh as int) as \"kwh\"\n from used\n where kwh is not null`;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 1140,
        "wires": [
            [
                "ce0dde258edf86ae"
            ]
        ]
    },
    {
        "id": "07691c24cdc0a11a",
        "type": "inject",
        "z": "3ec042cc2b88ead8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 1140,
        "wires": [
            [
                "247626382557a383"
            ]
        ]
    },
    {
        "id": "f0ee7a20a2b3b935",
        "type": "debug",
        "z": "3ec042cc2b88ead8",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 800,
        "y": 1140,
        "wires": []
    },
    {
        "id": "a33f828b.b04e2",
        "type": "sqlitedb",
        "db": "/root/sqlite-data/power.sqlite",
        "mode": "RWC"
    }
]

```

My setup:  
Sqlite 3.34.1  
NR 3.0.2  
node-red-node-sqlite  
link to download database for testing: [power.sqlite](https://www.maxbox.cz/nextcloud/index.php/s/9LH55pYPDd2pgmH)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 December 2022 01:47 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/2 "2022-12-20T01:47:49Z")

</div>

Add a `catch` node connected to a `debug` node (set to display the complete msg object) and see if that shows anything.

Also remove all the `\NR from the query.

---

<div class="post-metadata">

**Author:** ![Petr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/petr/32/6413_2.png) [@Petr](https://discourse.nodered.org/u/Petr)\
**Post date:** [20 December 2022 01:50 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/3 "2022-12-20T01:50:06Z")

</div>

Nothing at all

---

<div class="post-metadata">

**Author:** ![Petr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/petr/32/6413_2.png) [@Petr](https://discourse.nodered.org/u/Petr)\
**Post date:** [20 December 2022 01:51 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/4 "2022-12-20T01:51:07Z")

</div>

> [@zenofmud](#):
>
> Also remove all the `\NR from the query.

What do you mean?

---

<div class="post-metadata">

**Author:** ![Petr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/petr/32/6413_2.png) [@Petr](https://discourse.nodered.org/u/Petr)\
**Post date:** [20 December 2022 01:54 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/5 "2022-12-20T01:54:37Z")

</div>

I have forget to mention simple query

> SELECT \* FROM POWER

works without any problem

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 December 2022 02:20 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/6 "2022-12-20T02:20:08Z")

</div>

Instead of using a function node to build the query, try using the template node

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 December 2022 07:27 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/7 "2022-12-20T07:27:10Z")

</div>

> [@Petr](#):
>
> sqlite3 power.sqlite ".read sql.txt"

I'm not certain that nodejs SQLite driver understands this syntax. If it does then this is probably a path issue.

You can avoid that altogether though. Instead, simply use a file node to read your text file, move the payload in the topic, then pass that through to the SQLite node.

---

<div class="post-metadata">

**Author:** ![Petr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/petr/32/6413_2.png) [@Petr](https://discourse.nodered.org/u/Petr)\
**Post date:** [20 December 2022 08:11 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/8 "2022-12-20T08:11:52Z")

</div>

Thks for the hint, but the result is the same.  
I wander which sqlite NR is using.  
If I uninstall sqlite manualy on my machine `apt remove sqlite3` the simple query `SELECT * FROM POWER` still works from the NR.  
Below are my attempts.

1. simple SQL query
2. complex SQL query via text template node
3. complex SQL query via function template
4. complex SQL query via fixed statement in the sqlite node

Only simple query works.  
sqlite is not installed manually on my server (not accessible from the command line on my server)

If I install sqlite manually on my server, complex query does not work from NR, but from the terminal on the server everything works as expected.

the database file is here: [power.sqlite](https://www.maxbox.cz/nextcloud/index.php/s/9LH55pYPDd2pgmH)

```auto
[
    {
        "id": "ce0dde258edf86ae",
        "type": "sqlite",
        "z": "3ec042cc2b88ead8",
        "mydb": "a33f828b.b04e2",
        "sqlquery": "msg.topic",
        "sql": "",
        "name": "",
        "x": 800,
        "y": 1100,
        "wires": [
            [
                "f0ee7a20a2b3b935"
            ]
        ]
    },
    {
        "id": "247626382557a383",
        "type": "function",
        "z": "3ec042cc2b88ead8",
        "name": "msg.topic query",
        "func": "msg.topic = String.raw`create index if not exists power_jd on power (julianday(timestamp), total_kwh);\n\nwith pwr(timestamp, reading, ratetoprior) as\n(\n select julianday(timestamp),\n total_kwh,\n (select(c.total_kwh - p.total_kwh) / (julianday(c.timestamp) - julianday(p.timestamp))\n from power as p\n where julianday(p.timestamp) < julianday(c.timestamp)\n order by julianday(p.timestamp) desc\n limit 1)\n from power as c\n order by julianday(timestamp)\n ),\nperiods(timestamp) as\n (\n select julianday(strftime('%Y-%m-%d %H', (min(timestamp)), '-1 month') || ':00:00.000')\n from pwr\n union all\n select julianday(datetime(timestamp, '+1 month'))\n from periods\n where timestamp < (select max(timestamp) from pwr)\n ),\nreadings(timestamp, reading) as\n (\n select timestamp,\n (select reading - (b.timestamp - p.timestamp) * ratetoprior\n from pwr as b\n where b.timestamp >= p.timestamp\n limit 1) as reading\n from periods as p\n where timestamp between(select min(timestamp) from pwr)\nand(select max(timestamp) from pwr)\n ),\nused(timestamp, kwh) as\n (\n select timestamp,\n reading - lag(reading) over()\n from readings\n )\n select strftime('%m.%Y', timestamp) as \"mm-yyy\",\n cast(kwh as int) as \"kwh\"\n from used\n where kwh is not null`;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 520,
        "y": 1160,
        "wires": [
            [
                "ce0dde258edf86ae"
            ]
        ]
    },
    {
        "id": "07691c24cdc0a11a",
        "type": "inject",
        "z": "3ec042cc2b88ead8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 1160,
        "wires": [
            [
                "247626382557a383"
            ]
        ]
    },
    {
        "id": "f0ee7a20a2b3b935",
        "type": "debug",
        "z": "3ec042cc2b88ead8",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1020,
        "y": 1100,
        "wires": []
    },
    {
        "id": "db673915dc44f66c",
        "type": "function",
        "z": "3ec042cc2b88ead8",
        "name": "simple query SELECT * FROM POWER",
        "func": "msg.topic = String.raw`select \n* from power`;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 1080,
        "wires": [
            [
                "ce0dde258edf86ae"
            ]
        ]
    },
    {
        "id": "829e92c901243fd4",
        "type": "inject",
        "z": "3ec042cc2b88ead8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 1080,
        "wires": [
            [
                "db673915dc44f66c"
            ]
        ]
    },
    {
        "id": "ee7d773fe9a4b153",
        "type": "catch",
        "z": "3ec042cc2b88ead8",
        "name": "",
        "scope": null,
        "uncaught": false,
        "x": 900,
        "y": 1040,
        "wires": [
            [
                "f0ee7a20a2b3b935"
            ]
        ]
    },
    {
        "id": "94ffcfb746384ecf",
        "type": "template",
        "z": "3ec042cc2b88ead8",
        "name": "text template in msg.topic",
        "field": "topic",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "plain",
        "template": "create index if not exists power_jd on power (julianday(timestamp), total_kwh); with pwr(timestamp, reading, ratetoprior) as ( select julianday(timestamp), total_kwh, (select(c.total_kwh - p.total_kwh) / (julianday(c.timestamp) - julianday(p.timestamp)) from power as p where julianday(p.timestamp) < julianday(c.timestamp) order by julianday(p.timestamp) desc limit 1) from power as c order by julianday(timestamp) ), periods(timestamp) as ( select julianday(strftime('%Y-%m-%d %H', (min(timestamp)), '-1 month') || ':00:00.000') from pwr union all select julianday(datetime(timestamp, '+1 month')) from periods where timestamp < (select max(timestamp) from pwr) ), readings(timestamp, reading) as ( select timestamp, (select reading - (b.timestamp - p.timestamp) * ratetoprior from pwr as b where b.timestamp >= p.timestamp limit 1) as reading from periods as p where timestamp between(select min(timestamp) from pwr) and(select max(timestamp) from pwr) ), used(timestamp, kwh) as ( select timestamp, reading - lag(reading) over() from readings ) select strftime('%m.%Y', timestamp) as \"mm-yyy\", cast(kwh as int) as \"kwh\" from used where kwh is not null",
        "output": "str",
        "x": 490,
        "y": 1120,
        "wires": [
            [
                "ce0dde258edf86ae"
            ]
        ]
    },
    {
        "id": "b690b9397c1e64fd",
        "type": "inject",
        "z": "3ec042cc2b88ead8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 1120,
        "wires": [
            [
                "94ffcfb746384ecf"
            ]
        ]
    },
    {
        "id": "c3f14e145fd45e79",
        "type": "sqlite",
        "z": "3ec042cc2b88ead8",
        "mydb": "a33f828b.b04e2",
        "sqlquery": "fixed",
        "sql": "create index if not exists power_jd on power (julianday(timestamp), total_kwh); with pwr(timestamp, reading, ratetoprior) as ( select julianday(timestamp), total_kwh, (select(c.total_kwh - p.total_kwh) / (julianday(c.timestamp) - julianday(p.timestamp)) from power as p where julianday(p.timestamp) < julianday(c.timestamp) order by julianday(p.timestamp) desc limit 1) from power as c order by julianday(timestamp) ), periods(timestamp) as ( select julianday(strftime('%Y-%m-%d %H', (min(timestamp)), '-1 month') || ':00:00.000') from pwr union all select julianday(datetime(timestamp, '+1 month')) from periods where timestamp < (select max(timestamp) from pwr) ), readings(timestamp, reading) as ( select timestamp, (select reading - (b.timestamp - p.timestamp) * ratetoprior from pwr as b where b.timestamp >= p.timestamp limit 1) as reading from periods as p where timestamp between(select min(timestamp) from pwr) and(select max(timestamp) from pwr) ), used(timestamp, kwh) as ( select timestamp, reading - lag(reading) over() from readings ) select strftime('%m.%Y', timestamp) as \"mm-yyy\", cast(kwh as int) as \"kwh\" from used where kwh is not null",
        "name": "",
        "x": 800,
        "y": 1200,
        "wires": [
            [
                "f0ee7a20a2b3b935"
            ]
        ]
    },
    {
        "id": "0c8e5351cf581324",
        "type": "inject",
        "z": "3ec042cc2b88ead8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 340,
        "y": 1200,
        "wires": [
            [
                "c3f14e145fd45e79"
            ]
        ]
    },
    {
        "id": "a33f828b.b04e2",
        "type": "sqlitedb",
        "db": "/root/sqlite-data/power.sqlite",
        "mode": "RWC"
    }
]

```

---

<div class="post-metadata">

**Author:** ![Petr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/petr/32/6413_2.png) [@Petr](https://discourse.nodered.org/u/Petr)\
**Post date:** [20 December 2022 08:24 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/10 "2022-12-20T08:24:56Z")

</div>

> [@Steve-Mcl](#):
>
> I'm not certain that nodejs SQLite driver understands this syntax. If it does then this is probably a path issue.

I am not using that format in the NR. `sqlite3 power.sqlite ".read sql.txt"`

it Is my test attempt from the command line to prove my SQL query is OK and it works properly.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 December 2022 08:34 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/11 "2022-12-20T08:34:47Z")

</div>

Use debug nodes to thoroughly examine the message topic going into the SQLite node.

Have a look at the SQL syntax you generate from your functions and template nodes.

You can even copy the debug output and test it on the command line.

One thing I do notice is that the database is in a root directory. Are you running node-red as root? Ps, don't!

---

<div class="post-metadata">

**Author:** ![Petr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/petr/32/6413_2.png) [@Petr](https://discourse.nodered.org/u/Petr)\
**Post date:** [20 December 2022 08:57 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/12 "2022-12-20T08:57:23Z")

</div>

> [@Steve-Mcl](#):
>
> Use debug nodes to thoroughly examine the message topic going into the SQLite node.
> 
> Have a look at the SQL syntax you generate from your functions and template nodes.

As mentioned in my first post, the result of the debug node is: `msg.payload : array[0] [empty]`

1. From the terminal/command line everything works.
2. From the NR simple query works (it means the path to the database is OK).
3. From the NR complex query does not work and does not return any error message (even "catch" node does not catch anything.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 December 2022 09:46 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/13 "2022-12-20T09:46:59Z")

</div>

> [@Petr](#):
>
> As mentioned in my first post, the result of the debug node is: `msg.payload : array[0] [empty]`

That does not mean you have carried out the test I suggested.

> [@Petr](#):
>
> From the terminal/command line everything works

Fine, but I dont know that what you produce in the function node is EXACTLY the same as the content of the `sql.txt` file. I will assume that it is the same.

> [@Petr](#):
>
> From the NR simple query works (it means the path to the database is OK).

I didnt suggest the path was wrong for the database, but rather the `sql.txt` file - however, I have now loaded your flow and can see you dont use that syntax in node-red (so moot point)

> [@Petr](#):
>
> From the NR complex query does not work and does not return any error message (even "catch" node does not catch anything.

It may be the NodeJS SQLite driver does not support multiple queries (I havent looked) - so what happens if you remove the `create index ... ;` part and simply run the CTE query part?

However, if the NodeJS SQLite driver DOES support multiple queries, try adding a semicolon at the end of the CTE since you are attempting to run multiple query operations - it might be something as simple as that.

---

<div class="post-metadata">

**Author:** ![Petr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/petr/32/6413_2.png) [@Petr](https://discourse.nodered.org/u/Petr)\
**Post date:** [20 December 2022 10:34 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/14 "2022-12-20T10:34:14Z")

</div>

> [@Steve-Mcl](#):
>
> It may be the NodeJS SQLite driver does not support multiple queries (I havent looked) - so what happens if you remove the `create index ... ;` part and simply run the CTE query part?
> 
> However, if the NodeJS SQLite driver DOES support multiple queries, try adding a semicolon at the end of the CTE since you are attempting to run multiple query operations - it might be something as simple as that.

BINGO.

Thanks for that. If I remove the first part of my multiple query SQL, everything works as expected.

Thanks a lot

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 December 2022 10:37 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/15 "2022-12-20T10:37:48Z")

</div>

@Petr I took a look at your database and the index is already defined for the table. Since the index exists and your create has a `create index if not exists`, nothing will happen.

If you drop the index you can recreate it but there will be no result returned because you are just creating it.

You can add an `inject` with msg.topic being set to `drop index power_jd;` and connect it to the `sqlite` node. Then you can run it and then run the original command to add the index to the `power` table schema.

---

<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:** [3 January 2023 10:38 UTC](https://discourse.nodered.org/t/sqlite-select-ok-from-terminal-empty-result-from-nr/72440/16 "2023-01-03T10:38:18Z")

</div>

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