# Update query in sqlite3 with fob id coming from gateway code

**URL:** <https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292>\
**Category:** General\
**Created:** [1 September 2020 10:08 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292 "2020-09-01T10:08:49Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 September 2020 08:58 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/81 "2020-09-07T08:58:30Z")

</div>

If you always want the timestamp to be the current time then you can define a datetime column with a default of the current time, then sqlite will automatically put the current time in for you. [https://stackoverflow.com/questions/200309/sqlite-database-default-time-value-now](https://stackoverflow.com/questions/200309/sqlite-database-default-time-value-now)

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 09:51 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/82 "2020-09-07T09:51:04Z")

</div>

yes ,it has  
Date\_and\_Time TEXT NOT NULL

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 09:52 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/83 "2020-09-07T09:52:11Z")

</div>

Sir for this i have to make another table in my DB right?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 September 2020 09:57 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/84 "2020-09-07T09:57:40Z")

</div>

No, why would you need to do that?

**[Edit]** Google for how to add a column to a table.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 10:00 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/85 "2020-09-07T10:00:49Z")

</div>

> [@shipra](#):
>
> Date\_and\_Time TEXT NOT NULL

Sir I have this already in my DB ,i have made this only for timestamping purpose

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 September 2020 10:03 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/86 "2020-09-07T10:03:29Z")

</div>

Well change it the correct column type and default value. These questions are nothing to do with node-red, they are about using sqlite.

---

<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:** [7 September 2020 10:21 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/87 "2020-09-07T10:21:14Z")

</div>

@shipra can you tell us why you are collecting the data? What will it be used for?

Knowing this may help us guide you to a solution.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 10:24 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/88 "2020-09-07T10:24:01Z")

</div>

Sir ,i making RFID project ,so for that node red I am using,  
i want the time when any person swap the card successfully and get updated in DB as well.(time also)

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 10:30 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/89 "2020-09-07T10:30:33Z")

</div>

not getting options

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

---

<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:** [7 September 2020 10:34 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/90 "2020-09-07T10:34:58Z")

</div>

But what are you going to use that data for? Are you looking to be able to tell all the times a preson opens the door?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 10:36 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/91 "2020-09-07T10:36:13Z")

</div>

yes sir,i want that time whenever a person opens a gate

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 11:35 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/92 "2020-09-07T11:35:03Z")

</div>

Sir drop command is showing error

> ALTER TABLE NCS\_DATABASE  
> ...\> DROP COLUMN Date\_and\_Time;  
> Error: near "DROP": syntax error

---

<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:** [7 September 2020 11:43 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/93 "2020-09-07T11:43:44Z")

</div>

> [@shipra](#):
>
> i want that time whenever a person opens a gate

If you want to know everytime a person opens the door, you need to ADD an new row to the database each time. If you just UPDATE a row, it will only show the LAST time the person opened the door.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 September 2020 12:37 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/94 "2020-09-07T12:37:41Z")

</div>

You can't drop a column in sqlite, you will need to drop the table and re-create it.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 12:51 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/95 "2020-09-07T12:51:59Z")

</div>

Acc to first scenerio,my db gets fulled and my ram gets filled and my code get stuck so any other way you know to accomplish first scenerio

---

<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:** [7 September 2020 13:36 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/96 "2020-09-07T13:36:03Z")

</div>

> [@shipra](#):
>
> Acc to first scenerio,my db gets fulled and my ram gets filled and my code get stuck

What are you running node-red on? how much storage do you have?  
How many times do you run it till the database gets filled up?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [7 September 2020 13:44 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/97 "2020-09-07T13:44:43Z")

</div>

Sir this node red i have to run on a arm board

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 September 2020 14:04 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/98 "2020-09-07T14:04:18Z")

</div>

Look at the questions @zenofmud just asked. How many of the questions have you answered?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [8 September 2020 05:54 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/99 "2020-09-08T05:54:32Z")

</div>

only for testing purpose i am doing this on my linux .So storage for now is not an issue.  
How can i implement your scenario 1.Kindly suggest.

---

<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:** [8 September 2020 08:57 UTC](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292/100 "2020-09-08T08:57:59Z")

</div>

If you are going to put this on another computer, it is important we know the features of that computer.

If you want help, please answer `all` of the following questions  
1 - what kind of arm computer will you be using  
2 - what operating system will it be running on?  
3 - how much ram does the computer have?  
4 - how much memory does the computer have?  
5 - how long - on the target computer - does it take before "`my code get stuck`"

[Previous page](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292.md?page=4)

[Next page](https://discourse.nodered.org/t/update-query-in-sqlite3-with-fob-id-coming-from-gateway-code/32292.md?page=6)
