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))
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 of databases - and we have a couple of "demos" of it in action [here]
Here's sample output from the second of those - not a line of SQL in sight!
WomanWithCat:flask grahamellis$ python alch002
<User(name='ed', fullname='Ed Jones', password='edspassword')>
IdentitySet([<User(name='ed', fullname='Ed Jones', password='f8s7ccs')>])
IdentitySet([<User(name='wendy', fullname='Wendy Williams', password='foobar')>, <User(name='mary', fullname='Mary Contrary', password='xxg527')>, <User(name='fred', fullname='Fred Flinstone', password='blah')>])
[<User(name='ed', fullname='Ed Jones', password='f8s7ccs')>]
(u'ed', u'Ed Jones')
(u'wendy', u'Wendy Williams')
(u'mary', u'Mary Contrary')
(u'fred', u'Fred Flinstone')
(<User(name='ed', fullname='Ed Jones', password='f8s7ccs')>, u'ed')
(<User(name='wendy', fullname='Wendy Williams', password='foobar')>, u'wendy')
(<User(name='mary', fullname='Mary Contrary', password='xxg527')>, u'mary')
(<User(name='fred', fullname='Fred Flinstone', password='blah')>, u'fred')
<User(name='wendy', fullname='Wendy Williams', password='foobar')>
<User(name='mary', fullname='Mary Contrary', password='xxg527')>
<User(name='ed', fullname='Ed Jones',password='f8s7ccs')>
But if we run it with echo on, you can see the underlying SQL - here's the end of the output with that switch thrown
2015-10-14 07:37:47,723 INFO sqlalchemy.engine.base.Engine SELECT users.id AS users_id, users.name AS users_name, users.fullname AS users_fullname, users.password AS users_password
WHERE users.name = ? AND users.fullname = ?
2015-10-14 07:37:47,723 INFO sqlalchemy.engine.base.Engine ('ed', 'Ed Jones')
<User(name='ed', fullname='Ed Jones', password='f8s7ccs')>
There's a very great deal to this ORM, including the echoing back to the database of changes made in memory (commit and rollback) and a whole extra library of functions to perform a wide range of tasks. The examples here are just "get you started" in the concepts! (written 2015-10-14)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesY113 - Python and SQL databases 
Connecting Python to sqlite and MySQL databases - (2010-04-28) 
Model - View - Controller demo, Sqlite - Python 3 - Qt4 - (2010-04-29) 
Factory methods and SqLite in use in a Python teaching example - (2010-05-29) 
Joining a MySQL table from within a Python program - (2010-06-02) 
A framework with python - Django - first steps - (2011-01-17) 
Steering our Python courses towards wxPython, SQLite and Django - (2011-01-19) 
SQL databases from Python - an SQLite example - (2013-03-02) 
Cacheing class for Python - using a local SQLite database as a key/value store - (2013-05-14) 
Accessing a MySQL database from Python with mysql.connector - (2015-02-21) 
Graphing presentations in Python - huge data, numpy and matplotlib - (2015-02-28) 
example of SQLite using a local database file through SQLalchemy - (2015-10-14)
Some other Articles
TransWilts public transport corridorFlask and unittest - hello web app test worldJson load from URL, recursive display, Python 3.4SQLAlchemy - first examples with a Python Object Relationship Mapping systemFlask - complete MVC site to navigate around a data setSessions in flaskFlask - first forms and responses with wtformsJinja2 - Flask templating Requests in Flask
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page
This is a page archived from The Horse's Mouth at
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.
Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).