Using text databases in Qt
-
To import csv into SQLite (for example) you should create new sqlite database, create table there, read your csv file line by line, parse each line and insert it into sqlite database. Nothing extra hard here.
But I think that another ZapB's solution is better (about sub-classing QAbstractItemModel) -
What's more: I know somebody has already "done that subclassing":http://libqxt.bitbucket.org/doc/0.6/qxtcsvmodel.html for you, and created a QAbstractItemModel that reads CSV files.
-
Andre, that's great. I think it will help OP to solve his problem.
-
ZapB, for me it looks a bit strange to use sql for csv :)
-
I think I can't describe what I really need. In this project there are various text database in CSV format with a single Schema.ini file. The .ini file includes description about records stored in each database. something like this:
@
[customers.txt]
customerID/name/last/
delimiter=';'[sales.txt]
customerID/stuffID/count/fee/date
delimiter=';'
@then we should use a SQL command object to interact with data. like this:
@
"select * from customers.txt where ..."
@which returns an array of System.Object. libqxt (what Andre says) is great for working with CSV's but I can't find a way to use sql with that model.
-
So sql is required? In this case I think the best approach is firstly convert csv to sqlite and after it use sqlite databases.