views:

16

answers:

1

Hi guys,

I have this error when i perform the following task,

results = db1.executeSelectCommand(siteSql, (),) TypeError: unbound method executeSelectCommand() must be called with dbConnn instance as first argument (got str instance instead)

My code is as follows:

class dbConnn:
    db_con  = None
    execfile("/Users/usera/Documents/workspace/testing/src/db/db_config.py")

    def executeSelectCommand(self,sql,ip):
        #psycopg connection here.

I use this class here:

from db import dbConnections

db1 = dbConnections.dbConnn

siteSql = 'select post_content from post_content_ss order by RANDOM() limit 500' #order by year,month ASC'
results = db1.executeSelectCommand(siteSql, (),)

In windows, there don't seem to have a problem with this? God, it must be really elementary but I can't find it.

A: 
db1 = dbConnections.dbConnn

Here you assign the class dbConn to the variable db1. You probably wanted to create a new instance instead:

db1 = dbConnections.dbConnn()
sth
@sth, thanks. pardon me for such a stupid mistake.
goh