Storing inputs in db

Hi,
I’m developing this calculation tool with twenty or so inputs and a result page to display results.
I’m passing input page as an object to result page so that user can go back and edit without having to fill in the whole form again. This works great.

Now I’m trying to build a database for the users to store projects. Of course I could go the route of passing all the inputs to a table and fill the form in some way from database, but then again if I can store the object in a variable, can’t I just store this variable in the database as well and add component from database.

I tried storing it as a simple object but could not get it to work.
Any ideas?

Kind Regards
Per

A simple object column is the right way to go, but without seeing what you’ve already tried and hearing how it isn’t working, it’s hard to say what might be going wrong.

I will note that simple object columns only hold basic Python data structures, e.g. lists, dictionaries, ints, strings, etc. The blog post about simple object columns covers this: Simple Object Storage

If you’re trying to put something else into simple object storage, it won’t work.

2 Likes

Great thanks,
Now I know I’m on the right track, I can probably solve it by reformatting what I did then. By the way, different question, I would like to keep this on a separate database with my external server, what do you recommend I try. A few thousand users keeping track of their projects, do all the SQL variants have this column type. I’m mostly developing calculations for backend and I’m using simple sqlite3 read only for the calculation data on the server that works great for this project. I guess it’s not recommended to use lite for the users in this case.
Kind regards
Per

Off the top of my head PostgreSQL and MySQL (MariaDB) have had JSON columns since 2012 and 2015 respectively, the simple object column in the Anvil DataTables is essentially just using a PostgreSQL JSON column.

If you are only using the information for storage, and not for searching through the JSON column to find specific keys (the DB’s in question are optimized to do just that), then nothing is really stopping you from just storing the JSON data as a string in a TEXT type column, (or VARCHAR or even a BLOB if you want to store in in bytes, or compress the data if you are planning on having hundreds of thousands of users but need no ability to search through the data)

If SQLite and uplink isn’t going to handle that many simultaneous users, then the next easiest solution I can think of is to install docker on your computer and run a containerized version of one of the databases mentioned above, having a python script interact with it using uplink.

In the long term you might even look into moving the uplink and script into the container after you are done with development.

1 Like

Hey, many thanks for the explanation. No they don’t need to search the variable column just the name of the projects connected to their username so that should work. Just started with docker containers since business probably would need to set up servers at different locations for some of their reps down the road. This also gave me a road map to put the db for customer and project in a separate container, Articles and such in a separate container, then separate anvil apps for reps for new set of containers. Kudos to you for that. More to learn and test out, love that.
Kind Regards
Per

Wow, that sounds like a level of complexity required for managing millions of users!

I have hundreds of apps and tables, and zero containers, just the Anvil account on a dedicated server, allmanaged by Anvil.

If you really need that level of complexity, good luck and kudos for setting it up.

2 Likes

I don’t like to make things over complicated, front end is simplistic, backend is where it happens and has been my focus up till now, Anvil is such a great tool, but have left to test putting the app at my dev server as well. This app will not get too much traffic, it’s a sales support tool for engineers in a special field, but business is worldwide and some markets like China have strict regulations on hosting outside the country. So I need to prepare for multiple deployments and expanded functionality. They did not have to think about location before, since this app will replace an old 32 bit windows program they use today. This will be my first “public” deployment. I certainly need all the luck I can get, so thank you.