2012-09-24 26 views
4

這是一個新的,我還沒有在其他stackoverflow網站上發現任何提及。RPostgreSQL訪問數據庫,錯誤:無法找到函數「show」的繼承方法,用於簽名「PostgreSQLConnection」

所以我在R編程,並使用RPostgreSQL包訪問Postgres 9.1.5數據庫。所以我創建了與數據庫的連接,正如我通常所做的那樣,現在我收到了一個奇怪的錯誤。

db.conn = function(){ 

    ## This function creates a connection to the database. Subsequent 
    ## functions that access the db will go through this function. 
    drv = dbDriver("PostgreSQL") 
    con = dbConnect(drv, user = "user", password = "password", dbname = "dbname", host = "localhost", port = 5432) 
    return(con) 
} 

所以當我創建一個對象:

testdb = db.conn() 

的對象似乎生成,但是當我鍵入

testdb 

Error in function (classes, fdef, mtable) : 
    unable to find an inherited method for function "show", for signature "PostgreSQLConnection" 

我從來沒有見過這個錯誤。有關它可能來自哪裏的任何建議?任何幫助,將不勝感激。

回答

1

請不要交叉郵寄。我剛纔回答的RPostgreSQL名單上過,說這個工作對我蠻好:

R> library(RPostgreSQL) 
Loading required package: DBI 
R> drv <- dbDriver("PostgreSQL") 
R> con <- dbConnect(drv, user = "edd", password = ".....", dbname = "......", 
+     host = "localhost", port = 5432) 
R> con 
<PostgreSQLConnection:(21267,0)> 
R> 
+0

謝謝你的幫助德克。嗯,我仍然得到錯誤,但它似乎像連接對象工作正常。我想知道它是否可能與我的Postgresql版本有關?但無論如何,現在看來這不是問題。再次感謝。 – krishnab

+0

我遇到同樣的問題,並且添加您提到的參數對我沒有任何幫助。 con < - dbConnect(dbDriver('PostgreSQL'),db ='....',user ='SYSTEM',password ='....',host ='localhost',port ='5432') 我仍然收到上述@krishnab所述的錯誤。連接工作正常,直到我開始創建用戶來正確處理來自Jenkins的連接。 – JAponte

+0

好的......出於某種原因,我清理了我的工作區,重新定義了con,現在它打印得很好。 – JAponte

1

如果這是對別人有幫助的,我收到了類似的錯誤:

"unable to find an inherited method for function dbIsValid for signature "PostgreSQLConnection"

這發生在我無意中忘記將我的dbConnect調用的結果分配給連接對象。

所以這沒有奏效:

dbConnect(...)

但這並:

con <- dbConnect(...)

1

我有同樣的問題,因爲yours.My解決方法是刪除了「DBI」包並重新安裝它。這個對我有用。但它可能不適合你。你可以嘗試:

remove.packages("DBI") 
install.packages("DBI") 
+0

這對我有用:) –

相關問題