How can i save my data ( user - time ) to a database

i creat a bot can count time between 2 command
but i want to store it into a file ( database is good )
how can i do that

You should consider how much data there will be and what you intend to do with it. If you are just “storing” it as some sort of historical fact you can just write it to a file. Pick a format that enables you to export it to other apps easily.

If you intend it to be queried on a regular basis then setting up a DB may be worthwhile. I use SQLite and it works fine for my needs.

Oh I should add, if this is all you are storing then you might consider just making it part of a logger module. Then you have logging when you need it along with this data if/when you need it.

1 Like

hi
thank u for help me
i just create a sqlite for db but i want a cmd for up all the db to bot
do u have time i want to ask smth about that ;.;

Hi. Personally I always develop in the opposite direction. :slight_smile: I get my app working and then “refine” it to the point that I am happiest. You might not have the option here but I would be gathering the data in a file while I worked out how to get it into a DB.

How you connect the DB depends “mostly” on what other libraries you are using. I don’t know what web server you are using for instance. But generally speaking the database is a service made available to the rest of the app.

There are lots of examples to be found on the web that can explain things step-by-step. Ultimately if I want to know how many users their are in my User table (for instance) I can call a single function like:
dbSvc.User.getUsersCount();

If you are unfamiliar with database access such as this I suggest that you study it a bit first.