Main Content
Python to MySQL Archive - Originally posted on "The Horse's Mouth" - 2006-03-31 06:46:22 - Graham Ellis
We've added some Python to MySQL connection examples on our web site - using the mysql-python open source download from sourceforge.
For the installation, you MUST ensure that you have the MySQL include files and libraries installed before you attempt a build, and that you set your PATH to point to that version of MySQL - otherwise you can get a rather frightening page full of errors. Here's a checklist for you:
1. Install MySQL into /usr/local
2. set up mysql-python
download, unzip and untar, cd to directory.
export mysqlclient=mysqlclient
export PATH=/usr/local/mysql/bin:$PATH
python setup.py build
3. Install mysql-python
become administrator
python setup.py install
I've run the above on both Fedora and Suse ...
Sample program sources:
Hello PySQL world, documented
Bare bones application using recommended classes
Example of using a MySQL database from Python in a web based (CGI) application
Some other articles
Y115 - Additional Python Facilities Some gems from Intermediate Python Command line parameter handling in Python via the argparse module Json load from URL, recursive display, Python 3.4 Running an operating system command from your Python program - the new way with the subprocess module Json is the new marshall, pickle and cPickle / Python Python - an interesting application Handling JSON in Python (and a csv, marshall and pickle comparison) JSON from Python - first principles, easy example Teaching dilemma - old tricks and techniques, or recent enhancements? A demonstration of how many Python facilities work together Python regular expressions - repeating, splitting, lookahead and lookbehind Joining a MySQL table from within a Python program Factory methods and SqLite in use in a Python teaching example Running operating system commands from your Python program Python decorators - your own, staticmethod and classmethod Model - View - Controller demo, Sqlite - Python 3 - Qt4 Connecting Python to sqlite and MySQL databases Regular Expressions in Python Python - what is going on around me? Python - how it saves on compile time Serialization - storing and reloading objects Testing code in Python - doctest, unittest and others Python Regular Expressions A series of tyre damages Ignore case in Regular Expression Regular expressions made easy - building from components Turning objects into something you can store - Pickling (Python) Buffering output - why it is done and issues raised in Tcl, Perl, Python and PHP Sending an email from Python Python - listing out the contents of all variables Python 3000 - the next generation Keeping your regular expressions simple This article Splitting the difference What and why for the epoch Examples - Gadfly, NI Number, and Tcl to C interface The elegance of Python S156 - Interfacing Applications to MySQL Databases Accessing a MySQL database from Python with mysql.connector MySQL, MySQLi, PDO or something else - how best to talk to databases from PHP Needle in a haystack - finding the web server overload Perl - database access - DBD, DBI and DBIx modules How to display information from a database within a web page Joining a MySQL table from within a Python program Connecting Python to sqlite and MySQL databases Checking the database connection manually Mysqldump fails as a cron job - a work around Hiding a MySQL database behind a web page Uploading to a MySQL database through PHP - examples and common questions Downloading data for use in Excel (from PHP / MySQL) Easy selection of multiple SQL conditions from PHP Using a MySQL database to control mod_rewrite via PHP Viewing images held in a MySQL database via PHP This article Using a MySQL database from Perl mysql_connect or mysql_pconnect in PHP?