Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, March 2007
sqlite3 QSqlTableModel


Message 1 in thread

hello all

Do you have any clues with this special case?

Let's have a sqlite db. Then there is ATTACHed another one with the same
named tables. So we have for example:

db: main
tab: - AAA_table
db: db1
tab: - AAA_table

then the code:
QSqlTableModel * model = new QSqlTableModel(this,
QSqlDatabase::database(SESSION_NAME));
model->setTable(QString("%1.%2").arg(schema).arg("AAA_table"));
ui.tableView->setModel(model);

The "schema" variable depends on the user's input.

But it looks the setModel() method does not find the object with the
schema.tabname notation. I have to use only the table name. So there is
only the main.AAA_table used. No chance to specify another schema.

I've examinated the Qt4(.3snapshot) sources but it looks like the sqlite
driver does not count with attached databases at all.

Any help?

cheers
Petr Vanek


--
 [ signature omitted ] 

Message 2 in thread

Petr Vanek schrieb:
> But it looks the setModel() method does not find the object with the
> schema.tabname notation. I have to use only the table name. So there is
> only the main.AAA_table used. No chance to specify another schema.
> 
> I've examinated the Qt4(.3snapshot) sources but it looks like the sqlite
> driver does not count with attached databases at all.

Worked for me with the Qt 4.1 series. However, I'm accessing the 
attached DBs with "schema.table" and the tables in main with plainly 
"table".

HTH, Martin

-- 
 [ signature omitted ] 

Message 3 in thread

Martin Gebert wrote:

> Worked for me with the Qt 4.1 series. However, I'm accessing the
> attached DBs with "schema.table" and the tables in main with plainly
> "table".

Interesting. How did you call setTable() exactly? I mean how did you do 
tablename QString()?

I cannot get any data nor any error message from setTable("db.aaa");

petr

--
 [ signature omitted ] 

Message 4 in thread

Petr Vanek schrieb:
> Interesting. How did you call setTable() exactly? I mean how did you do 
> tablename QString()?
> 
> I cannot get any data nor any error message from setTable("db.aaa");

With "db" being the alias for the attached DB, I guess? Well, then you 
might want to check if the table is really attached, as the ATTACH 
command doesn't give you a message on error; search the archive for 
"Multiple databases with sqlite" for the related thread.
My previous answer was referring to accessing attached DBs in general; I 
didn't use QSqlTableModel in that project, but QSqlQuery, so I can't 
tell you if QSqlTableModel is causing problems here. You might want to 
verify that by using a simple query...

Martin

-- 
 [ signature omitted ] 

Message 5 in thread

Martin Gebert wrote:
>> Interesting. How did you call setTable() exactly? I mean how did you do
>> tablename QString()?
>> 
>> I cannot get any data nor any error message from setTable("db.aaa");
> 
> With "db" being the alias for the attached DB, I guess? Well, then you

sure

> might want to check if the table is really attached, as the ATTACH
> command doesn't give you a message on error; search the archive for
> "Multiple databases with sqlite" for the related thread.
> My previous answer was referring to accessing attached DBs in general; I
> didn't use QSqlTableModel in that project, but QSqlQuery, so I can't
> tell you if QSqlTableModel is causing problems here. You might want to
> verify that by using a simple query...

oic. I don't have any problems with schema.table in QSqlQuery too. But only
in QSqlTableModel. It looks like it's time for inheritance again :/

petr

--
 [ signature omitted ]