Archive for May, 2006

Pit and the Serveroom

Wednesday, May 31st, 2006

BEEP — still unceasingly — still inevitably BEEP! I gasped and struggled at each BEEP. I shrunk convulsively at its every BEEP. My ears followed its outward or upward whirls with the eagerness of the most unmeaning despair; they closed themselves spasmodically at the sound, although death would have been a relief, oh, how unspeakable! I still quivered in every nerve to think how slight a beeping of the machinery would precipitate that keen, glistening madness upon my bosom. It was hope that prompted the nerve to quiver — the frame to shrink. It was hope — the hope that triumphs on the server rack — that whispers to the death-condemned even in the dungeons of the Inquisition.

DailyWTF’ed

Monday, May 22nd, 2006


So I sent in a story to DailyWTF, and the editor (severely) dramaticized the story and even photoshopped the screenshot I sent in, but so what! The “WTF” part is true at least, even if the facts about it were warped. It’s probably better that the facts were warped anyways.

It’s a Little Funny

I had to teach a co-worker how to insert data from a comma separated value file to a PostgreSQL database table today, using Python as the scripting language. This utilizes the pyscopg2 database adapter for Python 2.4.

import psycopg2, sys

try:
	conn = psycopg2.connect("""dbname='mydatabase'
		user='mikeatlas'
		host='localhost'
		port='5432'
		password='apassword'""")
except:
	print "Unable to connect to the database"
try:
	myfile = open('mydata.csv', 'r')
	for line in myfile:
		splitlineArray = line.split(',')
	cur = conn.cursor()
	sqlStatement = """INSERT INTO myTable
			(col0,  col1,  col2,  col3,  col4)
			VALUES ('"""+splitlineArray[0]+""",
				'"""+splitlineArray[1]+"""',
				'"""+splitlineArray[2]+"""',
				'"""+splitlineArray[3]+"""',
				'"""+splitlineArray[4]+"""')"""
	cur.execute(sqlStatement)
except:
	print "Error looping file into database"
try:
	conn.commit()
except:
	conn.rollback()
	conn.close()
	print "Error with transaction"