I am an "old" computer engineer & programmer, not old enough to have a punch card story but old enough to - have owned a Zx-81 - programmed in Motorola 6809 assembler - remember when 64K was lots of RAM - fixed a hard disk by replacing the platter
Thursday, March 08, 2012
I am speaking at IIUG 2012 about using Python with Informix
The abstract of my Python talk is as follows:
Add a Python to your Informix programming toolbox
Python is an open-source, dynamically typed, object-oriented programming
language. It offers an easy learning curve and access to a vast array of libraries
including Informix database access. With implementations available for most
operating systems as well as the versions that run under the Java and .NET
virtual machines, you can add Python to your Informix database administration
and application programming toolbox. The presentation will give an overview of
the Python programming language, discuss the Python DBI and the libraries that
allow access to Informix databases.
Thursday, July 14, 2011
I am speaking at PyCon AU 2011 about CouchDB
"CouchDB (http://couchdb.apache.org/) is an open source, document-oriented NoSQL Database Management Server.It supports queries via views using MapReduce, and replication. The talk will give an overview of CouchDB followed by how to access and manipulate using Python. There are a number of python libraries for accessing couchdb and these will be quickly discussed followed by how to use one of these libs with a Python web framework. Also there will be an example of using a Python view server in place of the standard Javascript views provided by couchdb."
PyCon Australia is Australia's only conference dedicated exclusively to the Python programming language, and will be held at the Sydney Masonic Center over the weekend of August 20 and 21.
Thursday, May 19, 2011
Python Informix Database Connection Options
Python DB-API (http://www.python.org/dev/peps/pep-0249/) adaptors
- InformixDB http://informixdb.sourceforge.net/ The original DBAPI compliant database adaptor that wraps the Informix CliSDK. BSD License.
- ibm-db http://code.google.com/p/ibm-db/ IBM sponsored connector that provides Python, Django and SQLAlchemy support for IBM DB2 and Informix. Connects via the IBM DataServer component. Apache 2.0 License.
- mxODBC http://www.egenix.com/products/python/mxODBC/ Provides an interface to databases via an ODBC interface so supports Informix via Informix CLiSDK. Commerical License.
I have used both items 1 & 3 and they do work very well. Haven't used ibm-db as our sites normally only have CliSDK installed not IBM DataServer.
My preferred combination for Python Informix database access is using InformixDB in conjunction with SQLAlchemy. SQLAlchemy allows me to choose how abstracted I want to be with my database, allowing direct SQL thru to utilizing an ORM.
Saturday, January 22, 2011
I finally own a smartphone, and it's not an iPhone
Since a MacBook Pro is my development platform of choice (with VMWare Fusion allowing me to use Linux and Windows whenever I want to), and that I am a happy iPad user, it would be assumed that I would get an iPhone. Since there was already a glut of iPhones and Blackberries amongst my co-workers, and I have been envious of my Google friends and their Android phones. So a "droid" shopping I went. So what did I get - a powerful HTC or Samsung Galaxy, import a Nexus S? No, I purchased an affordable (AUD299), middle of the range Motorola XT5 running Android Eclair 2.1 Why? As I said previously, we wanted to test "real" usability and performance, and the majority of our users who had Andriod phones would not be running 2.2/2.3 or have the latest 1 GHz processors. As developers we need to remember that our users do not always have the luxury of upgrading when the next great piece of hardware and/or software arrives, and we need to ensure our applications perform well on a wide range of platforms. Certainly we should the extra capabilities of the latest devices, but also ensure a good experience for those users without the extras.
To-date I am very happy with performance of my XT5 and Eclair functionality. Now if I can stop writing little python scripts that do things on my phone, I can get back to testing the application performance.
Friday, September 03, 2010
SyPy Meetup - CoffeeScript & Test Driven Development
The meeting started with a lightning talk about CoffeeScript (http://jashkenas.github.com/coffee-script/) which is a little language that compiles into Javascript. CoffeeScript borrows some of it's syntax from Ruby, Haml and Python. The javascript it generates uses only the good parts.
Then Vaughan Allan (@vornstar) gave a presentation on TDD with Python. It was a good introduction of what TDD is and the benefits. Slides are here. Dylan Jay followed this with a case study on how he used TDD for Google App Engine project. Q&A became a vibrant discussion about the pros and cons of TDD, best practices etc which proved to me how valuable the monthly meetups are.
Thanks to Google for the venue, food and drink.
Tuesday, May 12, 2009
MSC Malaysia OSCONF 2009
- Executive Download - Panels and presentations to introduce Government and Business to Open Source.
- Developer - Modelled on OSDC, presentations by Open Source developers for developers.
- Community - Presentations for users of Open Source software.
As a developer who spends some time each year in Malaysia, and has seen some of the interesting things the Open Source community is doing there, I would recommend this event as a great reason to visit Malaysia.
Wednesday, November 28, 2007
My OSDC 2007 talks
This morning I gave a talk on web testing using twill and selenium remote control. A pdf of the slides can be downloaded:
Testing Web Applications with Scripting Languages
And this afternoon I spoke about Moonlight, the Mono implementation of Silverlight.
Moonlight - Shiny, Pretty Things with XML?
I had intended to blog about the various OSDC sessions I have attended, but thanks to the lazy web, Alan Green has already done it for me
Thursday, July 26, 2007
mod_wsgi 1.0 Release Candiate Available
Adal Chiriliuc has built Win32 binaries of the release candidate and these can be found here.
I have lucky enough to have been associated with the testing of mod_wsgi since it's inception and want to thank Graham for all his efforts in developing and releasing a WSGI adapter of high quality and functionality. Also thanks to other testers who kept Graham honest and busy. In my humble and most likely biased opinion, I think it will become the WSGI adapter of choice when serving Python applications under Apache.
Friday, July 06, 2007
Sydney traffic chaos disrupts SyPy meeting
- NetEpi Collection, a Web-based outbreak data management tool, written in Python and using open-source components and infrastructure, including the PostgreSQL database.
- NetEpi Analysis, a tool for interactive exploratory data analysis of large (10-100 million rows) population health/clinical data sets. It is mainly written in Python, uses Numeric Python (NumPy) and the R statistical environment.
Friday, April 06, 2007
Last nights Sydney Python Group Meetup
First Alec Thomas gave a talk about PyCon 2007 and what he felt were the 10 best talks he attended. Alec's presentation can be found here. Then Andrew Bennetts gave a talk about the Bazaar GPL Distributed Version Control Software. Andrew did a good introduction of what Bazaar can do, then used the rest of the talk time to answer questions. Based on the number of questions, there is certainly alot of interest in this software tool.
After the meetup had finished, a number of us with a thirst for more discussion and beer headed to the cafe/bar next to the Google building where access to happy hour prices had been extended for us. Had some interesting discussions including one with cafe owner about the ultimate ui design for a bar point of sale.
Thanks to Alan Green for his organising skills and Google for providing an excellent venue.
Monday, February 26, 2007
PyCon Envy
Saturday, February 03, 2007
Friday, February 02, 2007
mod_wsgi - simple and fast apache wsgi serving
Graham Dumpleton has been working on an Apache module called mod_wsgi. Quoting from his website:
"The mod_wsgi adapter is an Apache module that provides a WSGI compliant interface for hosting Python based web applications within Apache. The adapter is written completely in C code against the Apache C runtime and for hosting WSGI applications within Apache provides significantly better performance than using existing Python based WSGI adapters for mod_python. The module can be compiled for and used with either Apache 1.3, 2.0 or 2.2."
I have been lucky enough to get early access to the code and try it with my WSGI applications. I able to compile, configure and have mod_wsgi running a simple WSGI application under Apache 2.0.55 and Python 2.4.3 in under 5 minutes, Certainly a much better experience than I have had with mod_python. Since I have been testing it on my "gutless" laptop rather listing the results of my benchmarking, I will leave Graham to publish his more comprehensive benchmarking results. But I will make some observations. It appears to run simple WSGI applications at least twice as fast as mod_python and 15-20 times faster than using CGI. I was also able to run a number of my WSGI applications that use either Pylons or combinations of WSGI middleware with no problems. At yesterdays SyPy meeting, Graham showed it running Django. The official release will hopefully be in March.
SyPy Social Meetup
There was a wide range of topics discussed including:
- Unit Testing
- Software Deployment
- Distributed Version Control
- Apache and WSGI - more about this in another post
http://groups.google.com/group/sydneypython/web/sypy-home
Hope to see you in March.
Thursday, November 23, 2006
IronPython and trace style debugging
From the win32 python docs:
These modules allow one Python process to generate output via a "print" statement, and another unrelated Python process to display the data. This works even if the Python process generating the output is running under the context of a service, where more traditional means are not available. The module works on Windows 95 and Windows NT.
To enable this debugging, simply "import win32traceutil" somewhere in your program - thats it! This automatically re-directs the standard Python output streams to the remote collector (If that behaviour is undesirable, you will need to use win32trace directly.) To actually see the output as it is produced, start a DOS prompt, and run the file "win32traceutil.py" (eg, double-click on it from Explorer, or "python.exe win32traceutil.py") This will print all output from all other Python processes (that have imported win32traceutil) until you kill it with Ctrl+Break!)
So I decided you create something similar for IronPython. win32trace uses a memory mapped file for communication between the application and the trace collector. Since the only way I could find to use memory mapped files under CLI, relied on calls to unmanaged win32 api, I decided to use network UDP datagrams instead. Rather than writing something from scratch, I remembered a python script that I had used many years ago, creosote.py by Jeff Bauer. The original link to the script is broken, so I finally tracked a copy down in the Zope CVS. So I wrapped this code in a wrapper traceutil.py.
To use it, you just need to put this script in your IronPython or CPython path, and any output to stdout or stderr will be sent to the collector.
To start the collector:
ipy.exe traceutil.py
If the following code is run as a script by IronPython or CPython:
import traceutil
print "start"
a = "A"
# Create an error
import monty
the following would appear in the collector console running under .NET:
creosote bucket waiting on port: 7739
start
\n
Traceback (most recent call last):\r\n File E:\\IronPython\\IPCE-r4\\test_traceutil.py, line 6, in Initialize\r\n File , line 0, in __import__##4r\nImportErr
or: No module named monty\r\n
and the following would appear in the collector console running under Mono:
creosote bucket waiting on port: 7739
start
\n
Traceback (most recent call last):\n File test, line unknown, in Initialize\nImportError: No module named monty\n
Tuesday, October 31, 2006
Roundup and WSGI
Currently there is one unresolved issue: when using Roundup's internal authentication, after login the browser is not always re-directed correctly. This is not an issue for me as I use WSGI based authentication middleware.
10 Nov 2006
As of Roundup 1.3, Richard Jones has added a wsgi handler so I suggest you use that one instead.
Saturday, October 28, 2006
IronPython and ADO.NET Part 2
The Python DB-API is a specification created by the Python Database SIG for a consistent interface to relational databases. For CPython there is at least one DB-API compliant library for most of the relational database engines that are used today. As part of his fepy project, Seo Sanghyeon has created a set of wrappers that provide DB-API support for MySQL, PostgreSql, SQLite, Microsoft SQL Server and ODBC ADO.NET database drivers. Since one of the features of ADO.Net is to also provide a consistent interface to relational databases, you may question why do you need to use another layer for database access with IronPython. The answer is simple, the DB-API allows you to focus on the actual access and manipulation of the data and hides the low-level ADO.Net setup and management code. To show how the DB-API can simpify your IronPython code, the examples from the first post of this series have been modified to use the DB-API.
If you want try the example or use the DB-API with IronPython you will need to install it. You can either download the modules from here and copy to the IronPython Lib directory or build and/or install the IronPython Community Edition which includes the DB-API.
Creating a table example
The first section of code is only required so the examples will work on either *ix or windows platforms. In normal usage, there is no need to import dbapi.py directly, just import the DB-API module for the database you want to use.
import dbapi
try:
import sqlite3 as db
dbapi._load_type(db.assembly,db.typename)
connectstr = 'ip2country.db'
ip2country_create_table_ddl = '''
CREATE TABLE ip2country (
ipfrom INTEGER,
ipto INTEGER,
countrycode2 CHAR(2),
countrycode3 CHAR(3),
countryname VARCHAR(50),
PRIMARY KEY (ipfrom,ipto)
)
'''
except:
import odbc as db
dbapi._load_type(db.assembly,db.typename)
connectstr = 'DSN=ip2country'
ip2country_create_table_ddl = '''
CREATE TABLE ip2country (
ipfrom DOUBLE,
ipto DOUBLE,
countrycode2 CHAR(2),
countrycode3 CHAR(3),
countryname VARCHAR(50),
CONSTRAINT ip2country_pk PRIMARY KEY (ipfrom,ipto)
)
'''
Comparing this code with the ADO.Net example you see that the opening of the database connection, and create a command instance is automatically done by the DB-API module. The Python DB-API PEP specifies implicit transactions that are started automatically and committed or rolled back on demand, so compared to ADO.Net example , a commit is required.
dbcon = db.connect(connectstr)
cursor = dbcon.cursor()
cursor.execute(ip2country_create_table_ddl)
dbcon.commit()
dbcon.close()
Load the data example.
Compared to the ADO.Net example, the DB-API allows the IronPython code to be simpler as it handles the creation of Parameters. (Note to self: MS Access, bulk inserts and transactions == very slow)
dbcon = db.connect(connectstr)
import re
re_csv = re.compile(',(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))')
cursor = dbcon.cursor()
insert_statement= '''
INSERT INTO ip2country (
ipfrom, ipto, countrycode2, countrycode3, countryname
) VALUES ( ?,?,?,?,? )
'''
f = open("ip-to-country.csv")
print "Loading..."
for line in f.readlines():
if line.endswith("\r\n"):
line = line[:-2] # remove \r\n
else:
line = line[:-1] # just remove \n
print line
ipf, ipt, cc2, cc3, cn = re_csv.split(line)
cursor.execute(insert_statement,(ipf[1:-1],ipt[1:-1],cc2[1:-1],cc3[1:-1],cn[1:-1]))
dbcon.commit()
f.close()
dbcon.close()
Select some data example.
Instead of using the ExecuteReader as in the ADO.Net example, the fetch method of the cursor instance is used to get the query result.
def ip2number(ipaddress):
'''
Convert dotted IP address to number
'''
A,B,C,D = ipaddress.split(".")
return (int(A) * 16777216) + (int(B) * 65536) + (int(C) * 256) + int(D)
dbcon = db.connect(connectstr)
cursor = dbcon.cursor()
try:
ipaddress = sys.argv[1]
# Convert dotted ip address to number
ipnumber = ip2number(ipaddress)
except:
print "Error - An IP Address is required"
sys.exit(1)
select_statement = '''SELECT * FROM ip2country
WHERE ipfrom <= %s AND ipto >= %s
''' % (ipnumber, ipnumber)
cursor.execute(select_statement)
row = cursor.fetchone()
print "The location of IP address %s is %s." % (ipaddress, row[4])
dbcon.close()
Friday, October 27, 2006
IronPython Community Edition R3 Released.
- zlib, using System.IO.Compression.
- hashlib, using System.Security.Cryptography
- sqlite3, using generic DB-API module
You can download it from here or here.
Wednesday, October 18, 2006
Atom Publishing Server using WSGI
Saturday, October 14, 2006
Adding .pth file support to IronPython
'Damnit. Apparently IronPython doesn’t support .pth files. I’m not sure if I should expect this or not from a “1.0” product, but it’s sure annoying since it seems most libraries use them.'
For me, it is an issue due the fact that many of the libraries I want to use come as Python Eggs, and the easy-install.pth file is required if you want them to work. So I decided to see what was needed to add .pth support to IronPython. In the end it was not too hard as the logic to add the contents of the pth files to the sys.path is included in the CPython site.py. It needed a little modification, but if you add this code to IronPython's site.py, .pth files work.