Diceman Active Member Licensed User Jul 5, 2021 #1 re: [B4X] Cross platform Editable B4XTable + Form Example I downloaded the TableAndForms.zip file from https://www.b4x.com/android/forum/threads/b4x-cross-platform-editable-b4xtable-form-example.104766/ and it works fine. Is there a property in B4XTable that can access an existing SQLite table to get the user data? I ask this because the example is a little confusing for those of us who only use SQLite or other databases to store user data. The example application that I downloaded runs the sub LoadData to load the data from a CSV file into B4XTable1. The B4XTable library then (internally) converts the CSV data into a SQLIte table. When any row of the B4XTable is edited, deleted or added by the application, the SQLite table gets updated (not the original CSV file). When the application closes the contents of the updated SQLite table gets written back to the CSV file. This is all well and good for those who use CSV files. My question is, can a future version of B4XTable open an existing SQLite table directly without having to import the data every time the application is run and save it back to the CSV file? Maybe it's just me but this seems a tad inefficient. TIA
re: [B4X] Cross platform Editable B4XTable + Form Example I downloaded the TableAndForms.zip file from https://www.b4x.com/android/forum/threads/b4x-cross-platform-editable-b4xtable-form-example.104766/ and it works fine. Is there a property in B4XTable that can access an existing SQLite table to get the user data? I ask this because the example is a little confusing for those of us who only use SQLite or other databases to store user data. The example application that I downloaded runs the sub LoadData to load the data from a CSV file into B4XTable1. The B4XTable library then (internally) converts the CSV data into a SQLIte table. When any row of the B4XTable is edited, deleted or added by the application, the SQLite table gets updated (not the original CSV file). When the application closes the contents of the updated SQLite table gets written back to the CSV file. This is all well and good for those who use CSV files. My question is, can a future version of B4XTable open an existing SQLite table directly without having to import the data every time the application is run and save it back to the CSV file? Maybe it's just me but this seems a tad inefficient. TIA
EnriqueGonzalez Expert Licensed User Longtime User Jul 5, 2021 #2 You can load data with any source. Even major databases. The example uses csv but it is just an example, The rows of the b4xtable is a list that holds arrays, each item in that array is an item. You can load data with this method. B4X: Copy Dim data As List data.Initialize data.Add(Array(1, 2, 3)) data.Add(Array(4, 5, 6)) B4XTable1.SetData(data) Look for dbutils executememorytable for a specific sqlite example Upvote 0
You can load data with any source. Even major databases. The example uses csv but it is just an example, The rows of the b4xtable is a list that holds arrays, each item in that array is an item. You can load data with this method. B4X: Copy Dim data As List data.Initialize data.Add(Array(1, 2, 3)) data.Add(Array(4, 5, 6)) B4XTable1.SetData(data) Look for dbutils executememorytable for a specific sqlite example
Diceman Active Member Licensed User Jul 5, 2021 #3 Sure, I understand that. But using your method as well as the CSV method in the example, I would have 2 SQLite tables when the application is running. I would have to open MyCustData table and traverse through it, adding data to B4XTable1 using SetData etc., then when the user modifies B4XTable1 data it updates B4XTable1's internal SQLite table. When the app is finished I have to write all that B4XTable1 data back to MyCustData table. I just think this is a lot of unnecessary data copying that could be eliminated if B4XTable could access an existing Sqlite table by specifying what columns you want to appear in the B4XTable grid and update that data directly. Maybe there is a reason for creating a duplicate SQLite table? I don't know. It just seems odd to me. Upvote 0
Sure, I understand that. But using your method as well as the CSV method in the example, I would have 2 SQLite tables when the application is running. I would have to open MyCustData table and traverse through it, adding data to B4XTable1 using SetData etc., then when the user modifies B4XTable1 data it updates B4XTable1's internal SQLite table. When the app is finished I have to write all that B4XTable1 data back to MyCustData table. I just think this is a lot of unnecessary data copying that could be eliminated if B4XTable could access an existing Sqlite table by specifying what columns you want to appear in the B4XTable grid and update that data directly. Maybe there is a reason for creating a duplicate SQLite table? I don't know. It just seems odd to me.
EnriqueGonzalez Expert Licensed User Longtime User Jul 5, 2021 #4 Diceman said: Maybe there is a reason for creating a duplicate SQLite table? Click to expand... I can think of 1, The sqlite handled by b4xtable is an in memory database which is faster but efimeral Upvote 0
Diceman said: Maybe there is a reason for creating a duplicate SQLite table? Click to expand... I can think of 1, The sqlite handled by b4xtable is an in memory database which is faster but efimeral
EnriqueGonzalez Expert Licensed User Longtime User Jul 5, 2021 #5 Another reason, you are assuming that the structure that b4xtable uses with sqlite will match with yours and thisof course its not true, But even then, you could ask for the source code and initialize sqlite with your database. If you make the proper adjustments it could work. Upvote 0
Another reason, you are assuming that the structure that b4xtable uses with sqlite will match with yours and thisof course its not true, But even then, you could ask for the source code and initialize sqlite with your database. If you make the proper adjustments it could work.
Erel B4X founder Staff member Licensed User Longtime User Jul 6, 2021 #6 Enrique Gonzalez R said: But even then, you could ask for the source code and initialize sqlite with your database. Click to expand... Everything you wrote is 100% correct. The source code is available inside the b4xlib (b4xlib = zip file). Upvote 0
Enrique Gonzalez R said: But even then, you could ask for the source code and initialize sqlite with your database. Click to expand... Everything you wrote is 100% correct. The source code is available inside the b4xlib (b4xlib = zip file).