In-memory "driver" for Zeos?

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

In-memory "driver" for Zeos?

Post by aehimself »

I think this question was asked already, but I could not find it on the forum. Is there a way to create a dataset in a ZQuery without having a database connection opened? I need to "simulate" results in a data-aware component and it would be awesome if Zeos could handle this for me.

As far as I recall there was a request for a webapi driver too (build a dataset from JSON / XML / something)... which could use the in-memory dataset "driver" to create it's dataset, maybe?
Unfortunately my knowledge is waaaaaaaaay too insufficient to implement this by myself, so is something like this already possible / in the queue? :)

Thanks!
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: In-memory "driver" for Zeos?

Post by aehimself »

I'm experimenting with TClientDataSet.CreateDataSet, but I really don't like the dependency on midas.dll. So far my options are creating a temporary SQLite database or forgetting data aware components, creating a two dimensional variant array and use a grid-like component to manually display the data.

- I don't like the first option because it depends on sqlite3.dll and because it seems overkill, and
- I don't like the second option because since I'm using a custom DBGrid descendant it would take waaaaay too much work to make the grid-like component to look and act like it
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Fr0sT
Zeos Dev Team
Zeos Dev Team
Posts: 280
Joined: 08.05.2014, 12:08

Re: In-memory "driver" for Zeos?

Post by Fr0sT »

Usually this is called "mem table" and it actually would be pretty nice to have this in Zeos.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: In-memory "driver" for Zeos?

Post by marsupilami »

Regarding TClientDataset: As far as I remember, it is enough to add the MidasLib unit to the uses clause of your project to get rid of the dependency on the dll.

Regarding in memory on Zeos: Well - Zeos can do that to some degree. The metadata functions do that in some drivers. Dblib would be one such example. But there is no supporting infrastructure for doing that. I assume, one could come up with a solution that is similar to the ClientDataset and creates a valid ResultSet for a Dataset that already has fields defined. I am not sure though, if our TZQuery component is prepared to work on a IZResultSet that has no connection attached.

Also there was a user who wanted a driver for an in memory database: viewtopic.php?f=15&t=19163
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: In-memory "driver" for Zeos?

Post by aehimself »

I started to use TClientDataSet, but my DBGrid descendant component depends on Zeos so heavily (sorting, ordering by title clicks, extra information on it's own status bar, etc) I decided I'm not going to care about it.
For the time being I am creating a SQLite database and using a TZQuery for my needs. I'm not really happy with this solution, though :(
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: In-memory "driver" for Zeos?

Post by marsupilami »

hmmm - how should an in memory driver work? How should it get its data about the dataset structure? Should that be derived from TZQuery.FieldDefs? Or should there be some kind of specification in the TZQuery.properties like this:

Code: Select all

ZQuery.Properties.Add('structure=field1 integer, field2 varchar(40), field3 memo')
Would we expect the data to somehow survive a cycle of TZQuery.Close / TZQuery.Open?

Would we want the possibility to store data and reload it?
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: In-memory "driver" for Zeos?

Post by aehimself »

marsupilami wrote: 03.12.2019, 11:41How should it get its data about the dataset structure? Should that be derived from TZQuery.FieldDefs?
To keep the similarities with TClientDataSet I guess FieldDefs would be the ideal way to go: https://stackoverflow.com/a/275132
marsupilami wrote: 03.12.2019, 11:41Would we expect the data to somehow survive a cycle of TZQuery.Close / TZQuery.Open?
Data? No. Structure? Now that's interesting: if it could be kept that would be the best but since it's in-memory, discarding it would make sense too.
marsupilami wrote: 03.12.2019, 11:41Would we want the possibility to store data and reload it?
Store, like .SaveToStream / .LoadFromStream? It's quite easy to do (just save the structure / data in a custom format), but compatibility will always require end-users to make their own implementations anyway (store to XML, JSON, they don't need structure; only data, etc).
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Post Reply