Python, Lua, Tcl, C and C++ training - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, Ruby, MySQL and Linux / Tomcat systems
Well House Consultants
You are on the site of
Well House Consultants
Open Source Training Courses
hotel accommodation. You are welcome to browse and use
our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Well House Manor Resources
Object Orientation and General topics
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
C and C++ Resources
Web and Intranet Resources
Python module Y113
Python and SQL databases
Exercises, examples and other material relating to training module Y113. This topic is presented on public courses Learning to program in Python
, Python Programming
Data within a Python application can be held and referenced
many ways - in regular files, in XML, via a web server (such as
an HTML or RSS feed) and within a relational database. This
module looks at the two most commonly used databases in Python -
MySQL and SQLite, which both use the structured query language,
but use different internal models. In then shows how those
databases are used from within a Python program, how other databases
(which usually follow a similar model) may be used, and how
the databases are wrapped if you're using a web framework such as
|Articles and tips on this subject||updated|
|4537||example of SQLite using a local database file through SQLalchemy|
Here's an example of SQLite using a local database file through SQLalchemy. The SQL statements are hidden from the user - that's the "Object to Relation Mapping" - although you can ask what's going on by runing my program with a -v option. ... example program source [here], seeding data download from ...
|4535||SQLAlchemy - first examples with a Python Object Relationship Mapping system|
Object to Relational Database mapping - in other words how to you take objects in your language such as Python and save them in database tables, and vice versa, without having to do all the detailed SQL coding yourself? Use on ORM system. An example in Python is SQLalchemy which connects to a variety ...
|4445||Graphing presentations in Python - huge data, numpy and matplotlib|
A picture paints a thousand words. Our server log files for February are 1.6 Gbytes in size, with 5.3 million individual requests. How busy are we at what times of day? I've been looking at this through matplotlib in Python - here's a wireframe of the month - days on the X axis, hour of the day on ...
|4436||Accessing a MySQL database from Python with mysql.connector|
On our programming courses we often use SQLite as our database - it installs locally, saves us the need for daemons, saves licensing and password issues, and lets us cover the interfacing very quickly and easily. There's a Python example [here].
However, there are some occasions when a customer may ...
|4086||Cacheing class for Python - using a local SQLite database as a key/value store|
Question from Tom: What did you have for lunch yesterday?
Answer: A Sandwich, a piece of cake and some fruit.
Question from Dick: What did you have for lunch yesterday?
Answer: A Sandwich, a piece of cake and some fruit.
Question from Harry: What did you have for lunch yesterday?
Answer: A Sandwich, ...
|4024||SQL databases from Python - an SQLite example|
There's a new example of relational database use in Python [here] on our site - from the Python course I ran last week. If you cut and paste the script onto your system, it should run with little fuss (and without needing a separate database engine) as it uses sqlite - the built in SQL database - as ...
|3139||Steering our Python courses towards wxPython, SQLite and Django|
With our modular courses that we write ourselves, we've well placed to move forward with technology; more often than not, what's needed is a series of gentle changes, adding in the occasional module for private courses where a particular new subject is needed, with it being introduced into public courses ...
|3136||A framework with python - Django - first steps|
What is Django and what do I need to be able to use it?
Django is a framework - a tool that lets you create, customise, run and maintain web sites in which the data is stored in database tables. It uses the DRY (Don't Repeat Yourself) philospohy of design - quite the opposite of early web sites, where ...
|2790||Joining a MySQL table from within a Python program|
Python is a big subject.
MySQL is a big subject.
Yet the two fin so well together that they can be firmly linked, and work well together, using the tiniest drops of glue.
I've provided examples here before, but in answer to a request from a recent delegate, I've just added a fresh example onto our ...
|2786||Factory methods and SqLite in use in a Python teaching example|
I've just uploaded a neat little example - [here] from last week's Python course - it's amazing what you can do in a very few lines of code.
The application scenario is that we have a database of customers - some are residents at our hotel and others are delegates on our courses. Being mercenary folks, ...
|2746||Model - View - Controller demo, Sqlite - Python 3 - Qt4|
The Model - View - Controller approach to application design keeps the Graphic User Interface (the view) separate from the database (the model), with the controller in between the two, describing how the data is displayed, and how changes to the data are saved away in the database. By separating the ...
|2745||Connecting Python to sqlite and MySQL databases|
For developing a Python application, and for light use, the SQLite database may be a good choice ... but then you may want to be able to expand the system to use a central database with a more classic server such as MySQL at a later date.
Using Polymorphism in Python, and with a careful choice of which ...
Examples from our training material
|alch001|| SQL Alchemy - connect and first query|
|alch002|| SQL Alchemy - connect, inserts and queries|
|databases_python|| sqlite3 - connect, create, insert, select|
|inserts.py|| MySQL / Python (1) - connect, drop, create, insert, select, drop|
|kvcache.py|| Cacheing class object / sqlite3|
|logger|| Local MySQL test prior to running examples|
|multi_resultsets.py|| MySQL / Python (2) - connect, drop, create, insert, select with iterate, drop|
|napreader|| reading from http://www.wellho.net/data/wiltshire_busstops.csv|
|orm_sqlite|| sqlalchemy orm with sqlite demo - Python 2.x|
|prepared_statements.py|| MySQL / Python (3) - with prepared statements|
|pyjson_kvcache|| Using our JSON service from Python with key / value cache|
|selector.py|| Simple selector (MySQL database of 168,000 records)|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
A built in database - SQLite.
Connection to a database server.
Drivers for MySQL and other databases.
The basic principles of databases.
Using SQLite from Python.
Using MySQL and other databses from Python.
Checking your tables from the command line.
Databases in Django.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.