Python MySQL Getting-Started on Linux

  1. Installation
  2. Connection
  3. Insertion
  4. Query


Prerequisite: Setuptools and Pip Installed for your Python platform

To Getting-Started working with MySQL in Python you need to have Installed the Module MySQL-python.

Python Module Installation "EnvironmentError: mysql_config not found" in Linux

This should due to Missing Development Libraries from your MySQL Installation.

In Debian like in Ubunt you can easily resolve this probleme by installing the Package:

sudo apt-get install libmysqlclient-dev

After you can provide to Successfuly install MySQL Module for Python with:

Prepare to Install Python Modules with Setuptools and Pip


The Requisites to Install New Python Modules are at least to have the Python Setuptools Installed on your System.

To test if Setutools are present on your System, open a Terminal window and exec:

which easy_install

If Not look to this Python Tut -> Installing Setuptools

Download Webpage with Python and Urllib

The Python Urllib Module is present by Default on your System so you can make a little Python Script you call to Read and Save a Local Copy of a Webpage.

Open for Edit a File named for example and insert this code

Python BeautifulSoup Grab All Text Inside Html-Tag-Block

BeautifulSoup Dispose of a very Nice function that permit to Grab all the Text Contained Inside a Tag-Block.

For Example if you have an Html block to Parse like this:

<div class="first">
    <h3 class="second">The Title</h3>
    <a class="second">The Anchor
           <span class="third">The Span</a>

And you need to Get all the simple Text Contained inside of the Block marked by the <div> Tag.

Python Console Import All Modules at Once

When you Work enough on Console you easily are in a Situation of annoying Repeated Import Module Statements...

To make Working on Python Console a little bit Easier and Pleasant you can Pre-dispose an External File Containing the Import Declarations for all the Modules you need.


Python Switch/Change Version in Linux

We expose a Canonical way to Manage Multiple Versions of a program or Multiple Similar programs on Linux.

Requisite: update-alternatives

The package update-alternatives should be present by Default in your System but if you want to check:

which upadate-alternatives

Documentation about update-alternatives ->

Python Interpreting Text/Html/Xml Containing /u000a /u000d Unicode

The Unicode meaning for these symbols are corresponding to C Escape characters:

  • \u000a = \n (Line break)
  • \u000d = \r (Carriage return)

To Change the Interpretation of these Symbols by Python Interpreter you have to give a Different Encoding to the block with:


Selenium-Python Documentation

The Documentation for Selenium binding to Python API is on:

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer