Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Proposal: SqliteList #155

Open
annovialb opened this issue Jul 31, 2022 · 4 comments
Open

Feature Proposal: SqliteList #155

annovialb opened this issue Jul 31, 2022 · 4 comments

Comments

@annovialb
Copy link

Hello,
I am a happy user of the SqliteDict. Thanks for making it!

I would like to store a list as a table in the same sql file.
At the moment, in order to use the same sql file, I am storing the list as a value inside a dict.
This is highly inefficient since to add an element, I rewrite the whole list to sql.

I think it would be a pretty useful feature.
Just my 2 cents :)

@AndCycle
Copy link

I have same idea, after I think about this idea twice it's not as simple as it looks, how do you implement a List over sql database? definitely involve save additional information to work row as doubly linked list data structure which might hurt performance, left my 2 cents here I might implement a simple one for fun.

@annovialb
Copy link
Author

Hi,
thanks for they reply. I am not sure what a good implementation of a List in sql would be.
I am just throwing in a 2 cent idea. The primary key could be a floating point number stored as a string (or just float).
As the first elements are inserted, they are stored with key "0.", "1.", "2." ...
Inserting element(s) could use intermediate float values e.g. "1.5" then "1.75" to insert 2 elements in between "1." and "2.".

We are at 6 cents so far :)

@za3k
Copy link

za3k commented Nov 30, 2022

One can write a list-like wrapper around the sqlitedict, as a stopgap until this is implemented as a feature.

Here is what I did https://github.com/za3k/day29_adventure/blob/master/base.py#L18 . It's definitely not perfect performance-wise, just an example.

@WolfgangFahl
Copy link

Why not put the lists in their own table according to standard database normalization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants