For 2023 - we are now fully retired from IT training. We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here)) |

Well House Consultants
You are on the site of
Well House Consultants
who provide
Open Source Training Courses
and business
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
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk 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
Background 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
Django.
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 ... | 2015-10-14 | 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 ... | 2015-10-14 | 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 ... | 2015-02-28 | 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 ... | 2015-02-21 (longest) | 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, ... | 2013-05-18 | 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 ... | 2013-03-02 | 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 ... | 2011-01-21 | 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 ... | 2011-01-19 (longest) | 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 ... | 2010-06-02 | 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, ... | 2010-06-02 | 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 ... | 2010-04-29 | 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 ... | 2010-04-28 |
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) |
Background information
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.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.
Well House Consultants specialise in training courses in
Ruby,
Lua,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses 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.
|
|
|