MySQL question

Is there a way to use Panda3d to cooperate with MySQL? Something like PHP and MySQL combo?

My concern is that if I write some code with Panda3d, I will need to send login info to access server-side. The code is client-side, so any curious player/user could possibly decode it and retrieve the password. He could then access my db and mess things up. So is there a way to avoid the security problems?

Can I somehow exec SQL queries, just like you can with PHP? If not, can I somehow store/read the data in the SQL db in any other way?

MySQL or actually any other hybrid SQL dbs are quite strong, so it would be nice to make some use of them. Is it possible?

Using the MySQLdb Python module, you can use Python to execute MySQL queries: http://mysql-python.sourceforge.net/MySQLdb.html

Okay, firstly you need to understand that PHP runs server-sided. So, when PHP executes an MYSQL query, it is running server sided. After the query is executed the results are given to the user through the HTML page given out.

Secondly, there is no secure way to have a password in any file you’re giving out to users, this includes the game client.

The best way to do this is to only have the server execute the queries, just like a PHP-MYSQL combo does, since PHP runs on the server.

The only downside is you must write the server yourself, unless you want to use PHP and have your apache server return an html document that your client parses, could work too.

Securely speaking, server contact is the only way to go, there are no features I’m aware of in MYSQL that allow you to create user-specific accounts in MYSQL that can only modify user data.

I would look into creating a server that executes queries for authenticated users (whomever that may be in your case) and have it return data to your client.

Try something like Twisted, or Soap, or the like.

Also perhaps read up a bit on client-server communication.

Fetching an apache HTML document (that has PHP query MYSQL for data) could really work in your case, just look up Python HTML parsing, you could surely work something out.

Otherwise for faster server-client communication, try sockets instead of HTML/XML query/return models.

Hope this helps,
~powerpup118

Thanks. Yes, this is very helpful.

I should be fine at this point. You gave me some clues to investigate and work out a satisfactory solution. Indeed, perhaps a HTML document generated by PHP/MySQL or socketing would be a solution. I’ll probably try PHP/MySQL solution for a start. Might be a bit slow at first, but I’ll see if I can make it work. I can always try to convert later.

As indicated, I need to read more on Python HTML parsing and if I run into any specific problems I will get back to you.

Some versions of SQL might have tools to help in this department, but I’m not sure actually. I agree MySQL is really a “cheap” SQL and there are no sophisticated tools to do anything. You just run queries and you should be happy that you do it for free. :slight_smile: Other versions of SQL come with some really nice, interesting and powerful solutions.

I take it that Panda is mostly designed to send/read data via sockets? Is that how most of the MMOs work these days? I mean if you create a game that does not run in a browser, but you provide a game client. So you have to send/read data in a secure way. And so it’s not only SQL problem, it’s sending data from a game interface, which is client-side, while players data is stored on a server.

Again thanks. You gave me a broad perspective of how I can possibly address the issue, something I was looking for.

First, do you need to have login server(on internet)? Or you just need SQL storage? If you need SQL only for storage, look into SQLite.

Otherwise, if you really need to have online server for validation of some sort, use JSON as exchange format. I think its much better for basic stuff(99% of everything) than xml?

In php there are native json encode/decode functions, and json utils are also in python by default.

Easiest way to make it work would be to make http request with python and send data as json?

I do not know how familiar you are with json but its easy, for example this is json object

{username:"grizzly", password: "xxx"}

Just an advice, choose the right mysql library depending of the python version compliance.
The actual panda version uses python 2.6, but next release uses python 2.7.2.

All mysql library are not compliant with 2.7.2.

Thanks for your input. Appreciate it. This is another great idea and definiately a possible solution I will explore.

I actually would like to use server capacity to store and manage data and have write/read connection to panda. SQL gives you plenty of db possibilities to examine, sort, optimize and verify data. Easy to manage player character info.

It’s not validation of data, it’s full cooperation with Panda game client. In other words, I’d like to have players data on the server and have Panda retrieve it, process and write back. Same what you do with browser games.

I worked with SQLite, it’s rather simple, isn’t it? My idea was to use MySQL.

I am still a bit puzzled as to what network solution people use Panda with as a default. If someone could please clarify that, would be great.

I’m not very familiar with JSON, but my understanding is that it’s a format similar to XML used to transmit data between a server and web application. So indeed, it seems a good solution. I will investigate it.

The format seems easy and convenient indeed. Yet my major concern with this data format is data security. Isn’t it less secure than XML?