Python, an object-oriented scripting language, is considered to be
a well-designed language, with code that is easy to read and maintain.
Figure shows the state code application
written in Python.
#! /usr/local/bin/python
#
# Python sample program
#
import sys
from pg import DB # load database routines
conn = DB('test') # connect to the database
sys.stdout.write('Enter a state code: ') # prompt user for a state code
state_code = sys.stdin.readline()
state_code = state_code[:-1]
for name in conn.query( # send the query
"SELECT name \
FROM statename \
WHERE code = '"+state_code+"'").getresult():
sys.stdout.write('%s\n' % name) # print the value returned
This interface's source code is located in pgsql/src/interfaces/python.