PDA

View Full Version : Issue getting table data when using PSQL plugin to connect to Postgre database



jmf8241
28th March 2010, 05:48
Hi all,

I've recently been trying to connect to a PostgreSql database using the QPSQL plugin. I can connect to my database, but can't get info from any queries. The output from the SQLError class is given as following:
"Error: Relation "node" does not exist"
Line 1: Select * from Node

QPSQL: Unable to create query.

I tried using the SQL Browser demo to connect to my database as well. I have the option to connect using the QPSQL driver. I can connect to the database through here. When I click the arrow by my connection, all of the tables in my database are listed. However, trying to click on any of the tables yields the message "Unable to find table X". Attempting to write a select query in the query browser returns the same error listed above. My source to access the database is listed below...



TextStream output(stdout);
QSqlDatabase db = QSqlDatabase::addDatabase(DBDRIVER);
db.setHostName(DBHOST);
db.setDatabaseName(DBNAME);
db.setUserName(USERNAME);
db.setPassword(PASSWORD);
QSqlQuery qry;


if ( db.open() )
{
qry.exec("select * from Node");

QSqlError err = qry.lastError();
QString sErr = err.text();
output << sErr;

while(qry.next())
{
QString name = qry.value(1).toString();
output << name;
}
}
return qry;
}


If it matters I'm running QT 4.6.2 on Windows 7 and attempting to connect to PostgreSql 8.4 on Ubuntu. I can successfully get queries out of the pgAdmin tool that was bundled with PostgreSql. Any help is greatly appreciated. Thank you for your time and consideration.

jmf8241
28th March 2010, 05:52
nevermind, the similar thread function pointed me to this

http://www.qtcentre.org/threads/27776-QSqlTableModel-PSQL-is-unable-to-find-table-(due-to-casing)

Turns out I was just having a capitalization issue with my table names.