Skip to content
Advertisement

How to parse a LUA Table and push to SQL Database using Python?

I play a game called DCS (Digital Combat Simulator) and was looking to export in game statistics to a database and later recall with PHP on a webpage. The game saves code to a LUA Table and sample data is shown below…

Categories show the aircraft type, time in air, planes killed, type of plane, total planes killed, weapons, weapon types, hits, kills, shots, actions, losses, pilot death, crash, eject, pvp, kills, join date, last join, names and more.

JavaScript

I am seeking advice on how to separate the values in the sample data ( a way to parse LUA Tables to SQL via Python) and and tie them all to the UUID (Unique user identification) shown as the string “b3961df7f720c4288522019d0455fa4a” above.

The Python code I currently use to load all this data is as follows…

JavaScript

Is there any way to more easily parse the data from the LUA Table file, filter it into categories tied to the UUID, make it end parsing when seeing “– end of stats”, and push to a database for eventual display with PHP on a webpage?

Asking a lot, I apologize but I’ve researched for a while now with little results. Think I’ve got a decent foundation though.

Advertisement

Answer

How about just using Lua to parse the file?

JavaScript

Then you can use either pipe or temp file to connect the two programs

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement