Project

General

Profile

WAbstractItemModel in DBO?

Added by Mark Travis 2 months ago

Can I store a whole WAbstractItemModel in a database?

For example:

session_.mapClass("Project Model");

I'm reading in a .csv file to create a model for the end user, but I don't know how many columns will be in the model.

Since I'm manipulating the table data algorithmically, and not doing any complex multi-table joins (except to show ownership via /) I may as well pack up the whole model into the DB and retrieve it when they log back in.

Possible?


Replies (3)

RE: WAbstractItemModel in DBO? - Added by Mark Travis 2 months ago

Interesting, I can't put angle brackets in my post!

ok, using square brackets instead. So above should read....

session_.mapClassWAbstractItemModel;

And (except to show ownership via [User]/[AuthInfo])

RE: WAbstractItemModel in DBO? - Added by Korneel Dumon 2 months ago

No, this is not possible. A mapping in Dbo needs to specify the columns.
How come you don't know the columns? Are they like optional columns or still different? If so, you may be able to use a QueryModel to directly insert the data in a DB, making the optional columns 'null'.

I know it's possible to simply dump a csv-file into a database, but even then you need to first create the table (and thus know the columns).

Another possibility is to put all the csv in a single column 'userData' as text. We sometimes do this with json-data.

RE: WAbstractItemModel in DBO? - Added by Mark Travis 2 months ago

Interesting. Thanks for that direction!

I'm building a statistical analysis tool for a very specific use case, but there is no way to know what kind of data set will be analyzed.

Once it's in an Abstract or Standard model, it's really easy to work with. I think it would be ludicrous to upload any more than 30 columns, so I might use the optional column idea.

Part of the process is converting a column of data to a different normalization, so I was thinking of putting that "shadow" column in the ItemDataRole::User field of the data map in Abstract. I'm still trying to understand if I could/should use StandardItemModel instead. Is another way of thinking about StandardItemModel like a 3D table? Can I set up a StandardItemModel to represent a data grid of X, Y with a depth of two (using the InvisibleRootItem to add the shadow column?)

    (1-3/3)