Clients uploading to database
The script makes a POST request to your Django web server either with login/pwd or unique string.
The web server validates credentials and inserts data into DB.
I have a python script set up that captures game data from users while the game is being played. The end goal of this is to get all that data, from every user, into a postgresql database on my web server where it can all be collated and displayed via django
The way I see it, I have 2 options to accomplish this:

While the python script is running, I can directly open a connection to the db and upload to it in real time
During the game session, instead of uploading to the db directly, I can save out a csv file to their computer and have a separate app that will find these log files and upload them to the db at a later point

I like (1) because it means these log files cannot be tampered with by the user as it is going straight to the db - therefore we can prevent forgery and ensure valid data.
I like (2) because the initial python script is something that every user would have on their computer, which means they can open it at will (it must be this way for it to work with the game). In other words, if I went with (1) users would be exposed to the user/pass details for connecting to the db which is not secure. With (2) the app can just be an exe where you cant see the source code and cant see the db login details
My questions:

So in one case I'd be exposing login details, in the other I'd be risking end users tampering with csv files before uploading. Is there a method that could combine the pros of the 2 methods without having to deal with the cons?
At the very least, if I had to choose either of these 2 methods, whats the best way to get around its downfall? So is it possible to prevent exposing db credentials in a publicly available python script? And if I have to save out csv files, is there a way to prevent tampering or checking if it has been tampered with?