Network game using mysql

Aaron Brady castironpi at
Wed Apr 15 01:49:47 CEST 2009

On Apr 14, 4:14 pm, Tino Wildenhain <t... at> wrote:
> Hi,
> João Abrantes wrote:
> > Good evening,
> > I am making an online game that stores its data in a mysql database. The
> > thing is that I can't allow the players to interact directly with the
> > important tables of database (they could cheat if I give them access) so
> > I only allow them to write on a table named commands and then a python
> > program running on the server will interpreter that command and update
> > the important tables. For example, a user that wants to build an house
> > writes on the commands table 'build house', and then my python program
> > takes the resources of the user and gives him an house.  The thing is
> > that I need to have a program reading the command list in a infinite
> > while loop and I don't know if there is a better way to do this, I am
> > afraid that if the command list gets to crowed my python program may not
> > handle all the commands in time. And if I put two programs reading the
> > same command list sometimes they handle the command twice..
> You could use Postgres instead and write stored functions in python
> to access the tables. This would avoid your asynchrous approach
> alltogether.
> Regards
> Tino

Sorry, do not see the Orig. Post.

You could create a stored procedure out of the commands, and run
that.  You might be able to wrap them in a transaction statement too.

You need a control loop to execute the modifications you make, which
means you need a process to do it.  SQL has its own process, and your
clients have a process.

Would it be to your advantage to spawn a new process / subprocess /
thread to take care of it for you?  The new process has the advantage
that it could be fire-and-forget under the right circumstances.

More information about the Python-list mailing list