Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   Python With MySQL (http://www.programmingforums.org/showthread.php?t=10820)

Sane Jul 23rd, 2006 9:42 PM

Python With MySQL
 
Have any of you had experience with it? What are your takes on this combination?

I've heard there is PySQL, is that any different than MySQL with Python? What is the performance drop when using MySQL with Python, as opposed to MySQL with PHP?

And finally, is there a way to embed your MySQL database and client in to the Python Py2exe Executable, so a user does not need to install a separate MySQL client program in order to use your Python Application?

Wooh. Many questions off my shoulders. Thanks in advance.

DaWei Jul 23rd, 2006 10:16 PM

I've been planning to mess with it, but haven't. If you get there first, let us know. I doubt there would be much performance drop in a pro application, as the secret to speed in enterprise-sized apps is to let the DB do the grunt work and just handle the results.

Game_Ender Jul 23rd, 2006 11:59 PM

There are also python modules that map objects to databases (Object Relational Mappers, ORMs). The two I know are SQLObject, and SQLAlchemy. They both work with multiple databases on the back end (MySQL, PostgreSQL, etc.), and they handle all the SQL querying for you. You just define your classes and off you go. I have used SQLObject in turbogears, and it was pretty cool. I believe they also have the option to create hand tuned queries if you wish to increase performance.

free-zombie Jul 24th, 2006 3:48 PM

I have used the MySQLdb module. It's s straightforward SQL-centric module complying with the pyhon DB API 2. It works for me.
No idea about performance

Silvanus Aug 25th, 2006 11:11 AM

I've been playing with Turbogears, which uses SQLObject. I love it- an ORM makes DB programming so much easier! As to performance, it seems fast enough; I haven't benchmarked it.

EDIT: SQLObject uses MySQLdb to talk to MySQL.

Arevos Aug 25th, 2006 11:43 AM

Quote:

Originally Posted by Sane
I've heard there is PySQL, is that any different than MySQL with Python? What is the performance drop when using MySQL with Python, as opposed to MySQL with PHP?

Generally speaking, MySQLdb is the defacto MySQL module for Python. It uses the MySQL library bindings (programmed in C), so it's about as fast as is possible to get. It is also fully compliant with the Python Database API Specification, which is the standard way to interface with SQL databases from Python.

In terms of performance, Python should outperform PHP, given the same platform (i.e. if you're using mod_php under Apache, a fair test would use mod_python), as PHP is interpreted (IIRC), and Python is internally compiled into bytecode before execution, which, in general, tends to operate somewhat faster than a straight AST.

That said, I'd imagine all the PHP MySQL library is codedentirely in C or C++, whilst the Python library is partially coded in Python. I'd imagine the difference between them would be small, but it would be interesting to run some speed tests.
Quote:

Originally Posted by Sane
And finally, is there a way to embed your MySQL database and client in to the Python Py2exe Executable, so a user does not need to install a separate MySQL client program in order to use your Python Application?

Presumably. I can include OpenGL, SDL, GTK and wxWidgets libraries in a Py2exe excutable. MySQL should be no different.

Silvanus Aug 25th, 2006 2:48 PM

Quote:

Originally Posted by Arevos
Presumably. I can include OpenGL, SDL, GTK and wxWidgets libraries in a Py2exe excutable. MySQL should be no different.

I'm not so sure. MySQL isn't just a library; it runs as a service. For portable database applications like Sane's talking about, I would check out SQLite.

Arevos Aug 25th, 2006 4:53 PM

Quote:

Originally Posted by Silvanus
I'm not so sure. MySQL isn't just a library; it runs as a service. For portable database applications like Sane's talking about, I would check out SQLite.

Sorry; you're right. I thought Sane just wanted to include the MySQL client, but on closer inspection of the original post he wishes to include the database also (by which he presumably means the server?).

In such a case, SQLite seems the favoured option.


All times are GMT -5. The time now is 12:44 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC