Python Forum
Retrieve variables from the log and send to the database
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieve variables from the log and send to the database
#1
Hi, I need to write a bit of a complicated script (at least for me).
I need exactly this, on the path "C:\Users\pc\Documents\GTA San Andreas User Files\SAMP\" there is a file "chatlog.txt" and it contains a log (logical: D) and when the message of this the type in which the variables are marked (marked in green) and I need to get the variables that are marked in bold
[15:40:10] Player Hailender won the $50,000,000 lottery with a lottery 13
and it would be better to put them in a mysql database where I have a pre-created database "won" with a table "won" and columns "ID" (AUTO_INCREMENT), "price" and "number". Would it be possible to write to the database like this?
Reply
#2
(May-30-2022, 07:25 AM)klanhar1425 Wrote: Would it be possible to write to the database like this?
Of course it is. As a starting point, write Python code that will insert a single record (python tuple) (50000000.0, '13') in the database.
Reply
#3
(May-30-2022, 08:14 AM)Gribouillis Wrote:
(May-30-2022, 07:25 AM)klanhar1425 Wrote: Would it be possible to write to the database like this?
Of course it is. As a starting point, write Python code that will insert a single record (python tuple) (50000000.0, '13') in the database.

the problem is that I just don't know how to write in python, that's why I wrote here if there would be someone who can help me write such a script
Reply
#4
We are certainly willing to help you along the way, but not do it for you. If you want someone to do it for you pls post in the Jobs section.

Suggest: Write down in plain English the steps you will need to accomplish the task. Keep it as granular as possible - open file, read line, compare second item with the desired code... etc. Then start tackling the individual steps. When you get stuck, ask a specific question.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020