# How to update my sketch each time when sketch is complete run

**URL:** <https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [July 5, 2019, 6:40am UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515 "2019-07-05T06:40:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_nish](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/the_nish/32/5634_2.png) [@The\_nish](https://discourse.processing.org/u/The_nish)\
**Post date:** [July 5, 2019, 6:40am UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515/1 "2019-07-05T06:40:01Z")

</div>

i am taking data from my server and database. and each time i update my database manually but my sketch data is not update and its running previous data in loop.  
i want that if i change or update database then my sketch data is automatic update when sketch is complete run .  
i want use redraw(); but i don’t know how to use it and where is use it.

---

<div class="post-metadata">

**Author:** ![Glowtube](https://avatars.discourse-cdn.com/v4/letter/g/e9bcb4/32.png) [@Glowtube](https://discourse.processing.org/u/Glowtube)\
**Post date:** [July 5, 2019, 8:05am UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515/2 "2019-07-05T08:05:28Z")

</div>

Hey. Can you post some code so we can see where the problem is?  
To redraw(): It only sets a “flag” that the sketch has to be redrawn. It is not redrawn immediatly.  
Where do you call it?

---

<div class="post-metadata">

**Author:** ![The\_nish](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/the_nish/32/5634_2.png) [@The\_nish](https://discourse.processing.org/u/The_nish)\
**Post date:** [July 5, 2019, 8:19am UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515/3 "2019-07-05T08:19:13Z")

</div>

in the draw() function at last

---

<div class="post-metadata">

**Author:** ![Glowtube](https://avatars.discourse-cdn.com/v4/letter/g/e9bcb4/32.png) [@Glowtube](https://discourse.processing.org/u/Glowtube)\
**Post date:** [July 5, 2019, 8:21am UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515/4 "2019-07-05T08:21:57Z")

</div>

Calling redraw in draw can lead to problems. Maybe this could be one error

---

<div class="post-metadata">

**Author:** ![The\_nish](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/the_nish/32/5634_2.png) [@The\_nish](https://discourse.processing.org/u/The_nish)\
**Post date:** [July 5, 2019, 8:23am UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515/5 "2019-07-05T08:23:26Z")

</div>

so tell me where should i call it?

---

<div class="post-metadata">

**Author:** ![Glowtube](https://avatars.discourse-cdn.com/v4/letter/g/e9bcb4/32.png) [@Glowtube](https://discourse.processing.org/u/Glowtube)\
**Post date:** [July 5, 2019, 8:31am UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515/6 "2019-07-05T08:31:21Z")

</div>

Can you post some code so I can look?

---

<div class="post-metadata">

**Author:** ![Glowtube](https://avatars.discourse-cdn.com/v4/letter/g/e9bcb4/32.png) [@Glowtube](https://discourse.processing.org/u/Glowtube)\
**Post date:** [July 5, 2019, 9:23am UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515/8 "2019-07-05T09:23:59Z")

</div>

You could try to move everything but the connection to the database inside draw. From there you can update the scetch and dont have to call redraw

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 5, 2019, 5:47pm UTC](https://discourse.processing.org/t/how-to-update-my-sketch-each-time-when-sketch-is-complete-run/12515/9 "2019-07-05T17:47:03Z")

</div>

> [@The\_nish](#):
>
> i want use redraw(); but i don’t know how to use it and where is use it.

☹

Research:

> **[redraw() / Reference](https://processing.org/reference/redraw_.html)**
>
> Executes the code within draw() one time. This functions allows the program to update the display window only when necessary, for example when an event registered by mousePressed() or

> **[Redraw / Examples](https://processing.org/examples/redraw.html)**
>
> The redraw() function makes draw() execute once. In this example, draw() is executed once every time the mouse is clicked.

🙂
