I see many new anvil users struggling to load data sets into the data tables for the first time without having an example of how to avoid abusing the free resources while still loading your use case sample data under the 30 second limit provided by the server modules.
So I created this full example app.
Feel free to clone it and use it for testing, reference, ideas, or anything else.
It is not fast. That’s kind of the point. This is full starting off point that works with all the code examples imbedded in it.
If you want to add or optimize it go ahead!
Also, if you think you have something cool to add to it, feel free to mod it and re-post your own clone link. If I see good ones I will add them to the bottom of this top post if possible.
I have done as much work as I wish to do on this, feel free to try and break it and post the results if you like.
A few things:
- CSV Browser only processing:
The python csv library is not implemented yet in Skulpt so…
GitHub - evanplaice/jquery-csv: A jQuery CSV parser plugin. Battle Tested | Optimized | 100% IETF RFC 4180 Complete
- No Module needed - but Basic Python Free is gently supported
This was made to use no sever modules at all, but you can use the basic free python sever module without it timing out. Whether you decide to load so much data that it kicks you in the pants because you are slowly grinding close to the limit for so long is really up to you. Be nice.
- Data Tables
Make sure this is checked if you are starting a table from scratch:
Whatever you name your table will be used by the app. If you want the browser to do the table writing, you are going to have to give the client access to it. Please Remember to remove this access if you don’t want it granted forever.
- Custom Parsing
There is support for adding your own custom parsing python classes. If any of what I just wrote makes sense to you you should be able to figure out how they are implemented.
The current date and datetime column parsing are written to default to how the Anvil IDE exports a CSV file.
There is no such thing as ‘standard’ CSV data, so for example if your dates don’t look like a python
.strptime() format of
"%Y-%m-%d" and you do not change the default - well you’re gonna have a bad time.
- It just loads data to Anvil Data Tables.
This does not do anything else, It just loads data. if you load the same data twice, you will get a table with twice the data. There are no checks, for anything, duplicates etc.
If you want any of that, here is just a place to start!
Have fun and keep on number crunching.