Monthly Archives: February 2007

Those were the days :)

I’m listening to the music of Alturas while they playfully plucking there guitar through their latino style rendering of the song – Those Were the Days. Those were the days then when I’m exploring C++ with the gtkmm wrappers.

As Mary Hopkins loudly sings..

Those were the days, my friend
We thought they’d never end…

Definitely it ends with the coming of the more interesting Python. Though I still love programming in C++ (the output of my work is shown below) I’m hooked with Python right now.

Here are the output program for linux and windows using gtkmm .


compiled and run using windows gtkmm version…


compiled and run using ubuntu linux gtkmm version…

PySQLite Howto: Selecting Sql Column Names on SQLite Table

When somebody ask in the mailing list on how to extract a fieldname of a particular table of SQLite, the most common answer is that theres a specification of Python DBAPI2 on cursor object which has an attribute description.

In the Python Database API Specification v2.0 particularly on the cursor object, it states that:


This read-only attribute is a sequence of 7-item
sequences. Each of these sequences contains information
describing one result column: (name, type_code,
display_size, internal_size, precision, scale,
null_ok). The first two items (name and type_code) are
mandatory, the other five are optional and must be set to
None if meaningfull values are not provided.

Below is my implemention on extracting fieldnames:

from pysqlite2 import dbapi2 as sqlite
#connecting to book.db
conn = sqlite.Connection(“book.db”)
#creating a cursor for book table
cursor = conn.execute(“select * from book”)
for i in cursor.description: print i[0]
# The table fieldnames will be be then displayed. [/python]

The only limitiation of the attribute description in pysqlite is that only fieldnames is displayed. You may notice in the PEP 249 document that it is mandatory to include name and typecode. There is a documentation which explains why this incompatibility to DBAPI specification happens but we hope that it would be rectified on the later revisions.