2010-08-15 57 views
0

Python的psycopg2误差变化的环境中的OS当x

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

我的代码如下这个错误,当我执行以下任务:

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

    def executeSelectCommand(self,sql,ip): 
     #psycopg connection 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,(),) 

在windows中,这似乎没有问题?上帝,它一定是真正的初级,但我找不到它。

回答

0
db1 = dbConnections.dbConnn 

在这里,您分配dbConn给变量db1。您可能想创建一个新的实例:

db1 = dbConnections.dbConnn() 
+0

谢谢。请原谅我这样一个愚蠢的错误。 – goh 2010-08-16 03:25:27