Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 23rd, 2006, 8:42 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,840
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is offline   Reply With Quote
Old Jul 23rd, 2006, 9:16 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 23rd, 2006, 10:59 PM   #3
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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.
Game_Ender is offline   Reply With Quote
Old Jul 24th, 2006, 2:48 PM   #4
free-zombie
Programmer
 
free-zombie's Avatar
 
Join Date: May 2006
Location: Bavaria, Germany
Posts: 50
Rep Power: 0 free-zombie is an unknown quantity at this point
Send a message via ICQ to free-zombie Send a message via MSN to free-zombie Send a message via Yahoo to free-zombie
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
free-zombie is offline   Reply With Quote
Old Aug 25th, 2006, 10:11 AM   #5
Silvanus
Hobbyist Programmer
 
Silvanus's Avatar
 
Join Date: Aug 2005
Location: Hiding from... them...
Posts: 110
Rep Power: 4 Silvanus is on a distinguished road
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.
__________________
:wq
Silvanus is offline   Reply With Quote
Old Aug 25th, 2006, 10:43 AM   #6
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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.
Arevos is offline   Reply With Quote
Old Aug 25th, 2006, 1:48 PM   #7
Silvanus
Hobbyist Programmer
 
Silvanus's Avatar
 
Join Date: Aug 2005
Location: Hiding from... them...
Posts: 110
Rep Power: 4 Silvanus is on a distinguished road
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.
__________________
:wq
Silvanus is offline   Reply With Quote
Old Aug 25th, 2006, 3:53 PM   #8
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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.
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL with python? snipertomcat Python 2 Apr 13th, 2006 1:34 AM
[tutorial] Python for programming beginners coldDeath Python 30 Dec 14th, 2005 11:35 AM
Convert Python script to C++ code clanotheduck Python 17 Sep 25th, 2005 8:55 AM
Advanced Python Tricks Arevos Python 19 Sep 24th, 2005 7:39 AM
Python - A Programmers Introduction coldDeath Python 17 Aug 19th, 2005 12:41 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:28 AM.

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