-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Views #1147
Comments
How important is it for you to have support for views? |
it is the opinion of some people that views are seldom use in real programming being more a feature used academically. Do you oppose this opinion? Is your design dependent on views? I can only assume that it does!! |
I am using a 3rd party library which is expecting a specific database format which relies heavily on a single view. My past solution was to expect that a pre-defined database schema file was provided which matched that structure. This inflated the deployed app size, etc. So, instead, I am trying to use sqlite_orm to programatically create the database schema and manage it more smoothly. I realized that it wasn't working and I've identified the source as the one missing view. I am ok to programmatically create the view myself in terms of the modifying the sqlite file directly, if that's an option. Is there a way I can executor a manual hardcoded query on the sqlite file? That way I can manually create the necessary view? |
Maybe using storage.execute(...) or something? I am investigating this now... |
@lasyakoechlin what kind of SQL exactly do you need? BTW it is duplicate #306 |
I basically just need a hardcoded:
|
I don't need to query it or anything. I just need for the sqlite file to create the view so that it can be accessed by a third part library (where I supply the database file link) |
ok I see. Views is a very complex feature. And unfortunately it is not implemented in
Everything is implemented except views cause views is a very complex feature. To make it right first we need to make sure we have CTE feature. CTE is also a very complex feature but we can't skip it cause we can't cover all cases of SQL queries without CTE. Fortunately @trueqbit is working on CTEs here #1124 and one day it will be merged. Once it is merged we may think on views API for Thank you for providing an example. How do you expect to interact with your view? |
@lasyakoechlin if you don't need to query it so you can create a view outside of |
Yeah, so supplying it externally does work. The problem is that my re-design was trying to avoid supplying the file externally. So, I was wondering if I could use I guess I am wanting to know if there's a way for my to directly supply a string to the internal |
I understand this intent and I agree with you - this is what I do in my projects as well. But storage.on_open = [](sqlite3* db) {
sqlite3_exec(db, "CREATE VIEW IF NOT EXISTS view_name AS ...", nullptr, nullptr, nullptr);
}; |
That worked perfectly for my needs! Thank you. Another unrelated follow-up, when I was making my tables, I did things like this:
where MapTileInfo has the following structure:
Anyways, when I manually download the generated database file, I notice that despite me trying to add an index on row, column, zoom_level, there are no indexes which were created. Did I set something up incorrectly? Thanks! |
|
Maybe I got confused by the difference between creating an index and this:
|
@lasyakoechlin you can know for sure whether you have to see indexes if your db has |
Thanks for the help/support! I was using unique when i should have been using unique_index. I also found in your documentation that I needed to create the indices before the tables. Anyways, that, combined with the manual view creation, and everything is working as expected. Much appreciated! |
@lasyakoechlin thank to you! BTW you can improve your |
I was looking but couldn't find anything on the wiki or examples.
Is there a way to programmatically create views using sqlite_orm?
Thanks!
The text was updated successfully, but these errors were encountered: