0

I'm using C++ with QT 5.7.0 for processing some legacy DB (SQLite3).

The DB has many tables with names 00.00.00/00:00_data_N. I can properly get data from this tables with sql query like this:

SELECT * from '00.00.00/00:00_data_N' ORDER BY id

And I can't get column names for this table with, for example, folowing code:

auto r = _dataBase->record("00.00.00/00:00_data_N");
qDebug() << "Count: " << r.count();

I try to enclose the table name into double quotes ("..."), into single quotes ('...'), into square brackets ([...]), and I try to escape dots with backslashes. I also try to combine all described methods and no of them works.

How can I get the list of field names for a table with so difficult name?

murzagurskiy
  • 1,273
  • 1
  • 20
  • 44
  • 1
    Have you tried executing 'PRAGMA table_info(table_name);'? – cuda12 Jun 15 '19 at 18:02
  • @cuda12 as SQL query? – murzagurskiy Jun 16 '19 at 05:05
  • It returns nothing when I execute it as SQL query – murzagurskiy Jun 16 '19 at 05:12
  • Yes as a SQL query. The command should work even with the "complicated" table name - I'd run the command with a command line interface directly on the DB to verify the spelling. My assumption is that either your db-connection points to an empty datebase or the table doesnt exist. sqlite> PRAGMA table_info("00.00.00/00:00_date_N"); cid name type notnull dflt_value pk ---------- ---------- ---------- ---------- ---------- ---------- 0 ID TEXT 1 1 1 Name TEXT 0 0 – cuda12 Jun 17 '19 at 06:57
  • @cuda12 it is exist. I try to print database tables with `tables()` method and I can see my table. But I can't query it's column. I create a table with a name "a.b" for tests. And I can print table name from `tables()` for this database, but I can't print columns as well! – murzagurskiy Jun 17 '19 at 09:24

0 Answers0