Hello everyone,
I would like to create a backup system, with csv files so it could be done offline. I found the tutorials in this forum for changing remote databases but I coundn’t find a way to do so with a local csv. Is it possible ?
Hello everyone,
I would like to create a backup system, with csv files so it could be done offline. I found the tutorials in this forum for changing remote databases but I coundn’t find a way to do so with a local csv. Is it possible ?
If I understand you correctly, you’re trying to update a local .CSV database in the same way as you would a remote database?
Unless I’m mistaken, this is not possible.
A remote database is usually updated from its remote source (or server), and the database automatically updates itself depending on your settings.
Whereas for a local database, your app is built with data imported from the .CSV file at the time of build. To update this database would mean to update your .CSV file and rebuild your app with the updated data.
I hope this helps.
Well, at least that answers my question !
So I will figure out how to do otherwise. I still have a question : in order to change manually the database values (for debug purposes), I would like to create some widget to “access” to the databases in the app. But as I have many databases, create a whole bunch of widgets to access each database would be a little too much work (and would increase unnecessarily the app weight).
So my question is : how can I change the database connected to a widget ? I tried to use all of the actions available, but when I do so, the widget gets just not connected to any database. What did I missed ?
I tried (amoung many) : action “set database” with the name of the database, the url, the file name… Maybe it does not work for local databases ? Am I forgeting to do something after changing the database associated to the widget ?
I think I understand what you mean.
But assuming the widget connected to your database is a table, then if you used “set database” with a value, it would only create a new and empty database with a field name of that value and assign it to the table.
If you used “set database” with an already existing database, it would assign that database to your table.
URLs are meant for remote database; to download or update remotely (online).
“Import data to db” only updates the database to an empty one with a field name of the value you chose (it usually imports your value to the database as a field name).
What you would really need is “update row from from raw data”. This should manually update your database on the row you choose, with the value you choose.
But for some reason it doesn’t seem to work. I may be missing something but I also think @Michael would be able to help you better on this.
The “update row from raw data” does work, but it needs a Json value. I’m currently trying to create a system to export all my databases in Json, and copy/paste it back into the app.
But I have a problem : when I update my DB with the “update row from raw data”, all the widgets connected to the concerned database are out : they are not updated, or blocked.
I was wondering about the “change multiple fields” action : what does it requires ? I was trying to use it with a Json, but it does nothing…
Yes, “update row from raw data” apparently seems to work with .json database only (probably what I was missing).
But updating the .json database works fine and is reflected if your connected widget is a table. What widgets are connected to your database?
And yes, the “change multple fields” doesn’t seem to work for some reason, but I also think you can skip the long route and use the “change field” action. This manually updates your database on the row you choose, the field you choose and with the value you choose: works on both .csv and .json databases.
Many widgets are connected to my databases : text fields, images, sliders, listviews, etc… The ‘change field’ is useful, except when databases have dozens of fields ! It would mean hundreds of widgets and actions to proceed. Too heavy…
For my problem, it is quite random : sometimes the update will work fine, and sometimes everything will be blocked. Coundn’t find why yet… So I’m still trying to find a way to do so…
I’m disappointed that I can’t use actions like “remove all rows” and “import data to db” : when I do so, my “list” tables are broken. It’s like the “groups” can’t reconnect to the new rows…
If you wish, and if you have a little programming background, you may attempt to codify this part of the implementation through the inbuilt capabilities of Flipabit.
What I mean is, when you create an action to “change field”, you can extract its code by clicking on the three dotted icon below:
Then you can edit the code on a text editor like notepad++ in order to update the database for multiple fields at a go. This should avoid the redundancy of too many actions and reduce the heavy load.
So for example, if you use the action “change field” at the press of button to update a database with multiple fields like this;
When you extract the code in Flibabit, you can edit it to a general one like this:
import QtQuick 2.6
import CBlock 1.0
import QtQuick.Window 2.0
import CContentController 1.0
import CAppPaths 1.0
Connections {
target: document.childByName("Button 1").scriptAdaptor
onEventItemPressed: {
((document.childByName("Table 3").scriptAdaptor.actionSetValueByName("row1","field1","value1")) || (document.childByName("Table 3").scriptAdaptor.actionSetValueByName("row2","field2","value2")) || (document.childByName("Table 3").scriptAdaptor.actionSetValueByName("row3","field3","value3")))
}
}
Just replace row1, row2 and row3 with the row number (1, 2 or 3); replace field1, field2 and field3 with the field name (day, month or year) and also replace value1, value2 and value3 with any value you choose to update with (e.g. Wednesday, July or 1974).
NB: rows made for numbers cannot recieve alphabet values, and vice versa. Also include the “import” statements as above. From my little understanding, using the AND operator (&&) should have being the more correct syntax, but that didn’t work, so I used the OR operator (||) instead. You can also extend the code to include more fields if you wish.
Then select the connected widget, click the “code” icon below and insert the code:
This is the only option I can think of at the moment, I hope it helps.