Can I connect to IFastNet database with a Python script located on browser?

Hi any willing helper! :heart:
I am currently owning a website thanks to Infinity Free :
I am creating a game with Python and want to link it to the database of PHPMyAdmin.
I already know that we can’t link to the database with external app, as explained in the following post : Connecting to MySQL from an external application
Thus,I was wondering if by buying the Super Premium offer of IFastNet i was gonna be able to access the database with a script like the following (entering the values of PHPmyAdmin):

# Importing module 
import mysql.connector
# Creating connection object
mydb = mysql.connector.connect(
    host = "...",
    user = "...",
    password = "...",
    db ="..."

The game will be on browser and this file would allow to access the database and make some SQL statements along the game.
If so, then it would be super hyper cool, but I just want to be sure about it,
Thanks :grinning:

Hi and welcome to the forum! I think you can access it, but to be sure ask iFastNet through their support ticketing system as they know better.


I don’t have any Ifastnet account yet, so i cant click on your link: :sweat_smile:

You do not need an iFastNet account; the support system account is separate from a future client one.

For more information, you can read this article (and while it is written for those who have already upgraded, it may also be useful for those considering to upgrade):


iFastNet supports remote database connections. So what you want is possible.

Whether it’s a good idea is debatable of course, database connections are notoriously sensitive to latency, and having your game interact directly with the database makes it very hard to do any authorization checks and validation to prevent unauthorized changes to the database content. If this is just an experiment, it will work, but you may want to stick a PHP application in between to make sure that no undesired changes are made to the database.


I mean… I know who the players are : i will get their IP and enter it in remote SQL then.
But you mean that the game will lag?

It will certainly be slower then if the game and database were to be in the same building.


I do not recommend connecting to the database directly at all, definitelly use an API in order to fetch data from it for your game.
Otherwise unauthorized access to the database is granted by someone who is able to either view the source code of your game or reverse engineer it :upside_down_face:


Do you have a better solution to make a network game with python? I tried Socket but it is not very easy to use and lots of bugs occured.
Still, the account will be linked but maybe ingame info can be fetched by another way

How you decide to prevent botting is up to you, however a harder but better solution such as making use of socket is safer than just exposing the database credentials for the sake of picking the easier way.


the game wont be on platforms like steam or playstore and be exclusively downloadable on my website only by people who created an account and whom i verified manually, since the game is meant to stay between friends.
so basically all that matters now is lag

If you trust friends enough for it then go for it. But there is the possibility of someone else getting it.


will the update of sql database will take long enough to create a lag, according to you?

It depends on how many users are accessing the database.


is 10 max fine?

It depends on how you optimize it and how many times you access it, I cannot say much about it.


oh ok a lot i guess

It depends on the type of game. Many games have a centralized, online service that’s responsible for things like matchmaking, scoreboards, profiles and so on, and use peer to peer connections for ephemeral information like in-session movements and actions. How much you have of each depends on the type of game.

Having the visitor’s browsers connect directly to the database is a really bad idea. Database access permissions are not very fine grained. You can determine whether a database user can write to the user_profiles table, for example, but then they can update everything in that table, not just their own profile. You need additional logic on the server side to prevent that from happening, which plain MySQL permissions just cannot do.

And if you now think “but I have checks for that in my game”, remember that to make the database connections work, you have to distribute database credentials along with the game code. That means that these credentials can be obtained from the client.

That’s why it’s customary to have a server side application that implements the necessary logic to only allow players to see and edit the things they should be seeing and editing. With a HTTP (REST) API to access that functionality from the client.


What I would like is that people can see leaderboards, friends, and more on the website by connecting their account, so ingame info must be linked so now i dont really know what to do.
For ingame information like movements and everything i tried socket but it is very chaotic…

Then you would usually have a server side application to handle it. Our hosting isn’t suitable for that either due to limitations, but premium hosting could be used. You can either write the server application in PHP, or also write it in Python using a web framework like Django, Flask or FastAPI. Especially Django makes it quite easy to write basic CRUD functionality for your database with a lot more security.

With things like movement information, the most important thing you need is that it should be low latency. Nobody likes laggy game where the movement of other players is delayed a lot.

Sending the data directly from client to client is how it’s done most commonly I think, but you could also relay the information through a server. Regardless, I think you’ll need some way to push data to the client with state updates, which a relational database doesn’t do well. Websockets are one way to do it which can be hosted on a web hosting service. If not, you’re looking at building your own protocol, but then you’ll need something more flexible than web hosting.