SQLite User Forum

Special feature in sqlite: definite time triggers
Login

Special feature in sqlite: definite time triggers

(1) By anonymous on 2022-08-16 21:23:11 [link] [source]

I would like to have a monthly/yearly/daily trigger on the sqlite database. The reason is simple, I don't want to have to use Excel spreadsheets to organize my personal finances.

One way that I found innovative would be to have a trigger for a determined time. Let's say you want the same entry to be repeated n times. An easy way to do this would be to have a trigger for a set time, for example you can set an entry that repeats every month, year, day.

The problem with this approach is that I find it difficult for anyone to want this, as there are excel sheets for this, as well as apps that do this like google calendar, google tasks, etc.

The big advantage I see in this is that people who only deal with data and are not programmers, this can make life easier.

Another advantage is that by default sqlite has the concept of triggers that are triggered automatically from an event that represents an action on the table. But these events do not have a period of time to end or start and in this sense if they had a period of beginning, end or recurrence this could be better used by the ram. Remembering that this event will be repeated n times, which can generate even small or large data consumption depending on the computer.

Another advantage that I notice is that I can't see any database that has this feature, this feature could help me and many people who don't want to use excel.

I want to hear what you all think

(2) By anonymous on 2022-08-16 21:32:24 in reply to 1 [link] [source]

SQLite cannot guarantee to be running at the time you want the trigger to be fired, hence it cannot promise you to fire a trigger at a certain time.

A database server like PostgreSQL or MySQL is assumed to be running all the time, hence they can potentially make such a promise.

(10) By Holger J (holgerj) on 2022-08-17 14:35:19 in reply to 2 [link] [source]

And even in PostgreSQL you need some extension to do so, like pg_cron or pg_timetable.

Just because a "time trigger" is beyond the original idea of a database system, it's not included anywhere.

It's a typical request which can be fulfilled by an operating system, like task scheduler on Windows or cron on Linux and Unix.

So please don't ask one tool to take over the job of another.

(3) By anonymous on 2022-08-16 21:46:00 in reply to 1 [link] [source]

I think you may misunderstand what sqlite and indeed sqlite triggers are designed to do.

What you are describing seems to be a function of the program that you desire to create to display and enter your data.

Sqlite is the storage engine. You can store an entry for a repeating event, or generate multiple future occurrences very easily.

But what you are asking is like requesting your hard drive provides spell checking.

(4) By Chris Locke (chrisjlocke1) on 2022-08-16 22:11:25 in reply to 1 [link] [source]

This isn't the role of the database engine. This would be the role of the application that makes use of the database engine.

You can use a programming language that uses SQLite to talk to your database. Your application can trigger hourly, monthly or whenever you desire.

(5) By Karl (kbilleter) on 2022-08-17 06:59:58 in reply to 1 [link] [source]

(6) By Sunny Saini (SunnySaini_com) on 2022-08-17 13:24:34 in reply to 5 [link] [source]

Any example of such programs that are Windows based and Android based?

(7) By jose isaias cabrera (jicman) on 2022-08-17 13:36:04 in reply to 6 [link] [source]

Any example of such programs that are Windows based and Android based?

In Windows you can use SCHTASKS:

 9:31:22.76>schtasks /?

SCHTASKS /parameter [arguments]

Description:
    Enables an administrator to create, delete, query, change, run and
    end scheduled tasks on a local or remote system.

Parameter List:
    /Create         Creates a new scheduled task.

    /Delete         Deletes the scheduled task(s).

    /Query          Displays all scheduled tasks.

    /Change         Changes the properties of scheduled task.

    /Run            Runs the scheduled task on demand.

    /End            Stops the currently running scheduled task.

    /ShowSid        Shows the security identifier corresponding to a scheduled task name.

    /?              Displays this help message.

Examples:
    SCHTASKS
    SCHTASKS /?
    SCHTASKS /Run /?
    SCHTASKS /End /?
    SCHTASKS /Create /?
    SCHTASKS /Delete /?
    SCHTASKS /Query  /?
    SCHTASKS /Change /?
    SCHTASKS /ShowSid /?

you can also use various programming languages to manage it.

(8) By Keith Medcalf (kmedcalf) on 2022-08-17 14:16:52 in reply to 7 [link] [source]

Exactly. The Task Scheduler is a wee little program that initiates execution when the computer IPLs and has what is called "supervision" to ensure that it is running at all times that the computer is running.

Therefore, this program (the Task Scheduler) is capable of "doing things" (firing off other executable programs) based on the system clock. cron does the same this for unix-like systems.

In other words, you can write a program (or several) that does what you want and then use the Task Scheduler to execute them according to the schedule you have set in the Task Scheduler (or cron).

THe SQLite3 library does nothing (not even execute). What executes is a user-written application that uses the SQLite3 library to perform I/O to a "database" disk file. There is no practical limit on what this user-written application may do nor how it is triggered to execute.

(9) By Sunny Saini (SunnySaini_com) on 2022-08-17 14:19:38 in reply to 7 [link] [source]

In Windows you can use SCHTASKS:

Thank you.

you can also use various programming languages to manage it.

I don't know programming. I only use SQLite for my personal databases.

(11) By Ryan Smith (cuz) on 2022-08-17 23:55:53 in reply to 9 [source]

I don't know programming.

That is a hard obstacle when trying to use SQLite as it is mostly used as a compiled-in (or external) library to a program.

There are very many GUI database management applications out there to manipulate the data with, and of course the SQLite CLI tool will do near anything you can imagine to an SQLite database without knowing programming, and can do so based on a scheduled task as other posters have noted.

Even so, not being a programmer would make it hard to tap the full benefits of SQLite and it feels to me like you are trying to accomplish some very programmy type tasks. It's a bit like how not being able to drive really takes away from the benefit of having a car - you can still sit in it, can still be driven by someone else to a needed destination, but learning to drive yourself will open up new worlds of travel possibilities and freedom of destination, and perhaps even destiny. Ditto with programming.