Thursday, January 15, 2009


INSERT INTO statement with MySQLdb

One can insert column(s) data into mysql with the following python commands:

import MySQLdb
db=MySQLdb.connect(host="localhost",user = "root",passwd="123",db="mydb")
c.execute("""INSERT INTO StockData (ind,Name,yesterday,pricenow,perch,id) VALUES (%s,"%s","%s","%s","%s","%s")""" %(i, str(comp), str(yesterday),str(pricenow),str(perch),str(id)))

Without using db.commit(), the database will not get updated.
Here ind column is of type integer and rest are strings.

Saturday, January 10, 2009


How to create a new project in Code::Blocks

I was playing around with the free C++ IDE Code::Blocks.

This is the way to create a new C++ project.

Go through File->New->Project, select "Empty Project", click on "Go" and fill in the Project Name and (browse to) path.

Friday, January 9, 2009


Trying to avoid urlfetch errors in Google App Engine

I was having urlfetch download errors in my newsfeed aggregator India Hot News.

Modified code:

result = urlfetch.fetch(url)
except urlfetch.Error():

This seems to work temporarily.

Earlier the code was

result = urlfetch.fetch(url)
except Exception:

This "Exception" was working yesterday.
Gave Server Error today.

Let me see the modified code works fine or not.
This urlfetch errors are real glitches in Google App Engine.

This page is powered by Blogger. Isn't yours?