.. _intro-installation:

Installation
************

Requirements
============

   * You need Python v2.5 or later, or Python v3.1 or later.
   * MySQL server v4.1 and greater are supported. The Client/Server
     protocol of versions 3.23.x and 4.0 are not supported as well as
     'old passwords'.

.. _intro-installation-download:

Download
========

From the LaunchPad download website
-----------------------------------

You can download the latest release from `MySQL Connector/Python download website`_ on LaunchPad.

.. _`MySQL Connector/Python download website`: https://launchpad.net/myconnpy/+download

Development releases are only available as tar ball or zip archive.

From development repository
---------------------------

Installation of Bazaar_ is not covered but check out `their installation guide`_.

.. _bazaar: http://bazaar-vcs.org
.. _`their installation guide`: http://doc.bazaar-vcs.org/latest/en/user-guide/installing_bazaar.html

.. code-block:: bash

   shell> bzr branch lp:myconnpy mysql-connector-python

This will create a directory called ``mysql-connector-python``.



.. _intro-installatation-install:

Installation
============

Check the :ref:`Download <intro-installation-download>` section on how
to get MySQL Connector/Python.

On Unix like systems
------------------------------------------------

On Linux distributions, MacOSX, etc.. open a terminal
and do something like this:

.. code-block:: bash

   shell> tar xzf /path/to/mysql-connector-python-<version>.tar.gz
   shell> cd mysql-connector-python-&lt;version&gt;
   shell> python setup.py install
   
You might need administrator privilege for the last step, try:

.. code-block:: bash

   shell> sudo python setup.py install

On Microsoft Windows
------------------------------------------------

Unpack the Zip archive (or the tar ball), open a terminal and
change to the location where you unpacked the MySQL Connector/Python
distribution.

.. code-block:: sh

   shell> python setup.py install

Test it
=======

After :ref:`installing <intro-installation-install>` MySQL Connector/Python,
safe the following to a file called :file:mysqlconn.py and execute it:

For Python v2.5 and up:

.. code-block:: python

   import mysql.connector
   
   if __name__ == '__main__':
     cnx = mysql.connector.connect(user='root',password='yoursecret',
       db='INFORMATION_SCHEMA',host='localhost')
     cur = cnx.cursor()
     cur.execute("SELECT ENGINE FROM ENGINES ORDER BY ENGINE")
     for row in cur.fetchall():
       print row[0]
     cur.close()
     db.close()

For Python v3.1 and up:

.. code-block:: python

   import mysql.connector

   if __name__ == '__main__':
     cnx = mysql.connector.connect(user='root',password='yoursecret',
       db='INFORMATION_SCHEMA',host='localhost')
     cur = cnx.cursor()
     cur.execute("SELECT ENGINE FROM ENGINES ORDER BY ENGINE")
     for row in cur.fetchall():
       print(row[0])
     cur.close()
     db.close()
     
Now run it and you should get the list of supported storage engines your
MySQL server is running:

.. code-block:: bash

   shell> python mysqlconn.py
   ARCHIVE
   BLACKHOLE
   CSV
   FEDERATED
   InnoDB
   MEMORY
   MRG_MYISAM
   MyISAM

