[PYTHON] About data management of anvil-app-server

Preface It's nice to be able to run the app on ʻanvil-app-server`, but let's run the `News Aggregater` app created on the [Anvil](https://anvil.works/) site. Even so, it doesn't seem to move smoothly. .. .. I did some research.

Premise --You have already created the [News Aggregator](https://anvil.works/learn/tutorials/database-backed-apps) app in Anvil.

Environment --Ubuntu 20.04 LTS Japanese Remix --Hyper-V Manager 10.0.18362.1 - anvil-app-server v1.1

Download and run the News Aggregator app Once you've created your app, you can download it from `View history` with the` git clone` command.

Click "View history" anvil_newsaggrigator_download_1.png

Click "Clone with Git" anvil_newsaggrigator_download_2.png

Copy the line "git clone ssh: // ~" and execute it with the command. anvil_newsaggrigator_download_3.png

git clone ssh://[email protected]:2222/324IEWAMVBYU2Y77.git News_Aggregater
  • XXXX is the email address of the account registered on the Anvil site.
  • If you have enabled two-factor authentication, you will have to use the SSH public key, so if you are using it, temporarily remove the two-step verification. I think it will be easier if you register a public key in Git.

Launch the application with ʻanvil-app-server`.

anvil-app-server --app News_Aggregater

Access http: // localhost: 3030 with a browser. anvil_app_server_url.png

Suddenly an error. anvil_app_server_NewsAggrigator_error.png

Problems In the News Aggrigator app, the article `category` is registered in advance in the` categories` table and selected from there, but since the app does not contain table data, "empty data" Will result in an error.

Access PostgreSQL of anvil-app-server with pgadmin4 ʻAnvil-app-server` contains its own PostgreSQL server, so access it.
  • Username : postgres --Password: (directory where anvil-app-server was executed) /.anvi-data/postgres.password --Port: (directory where anvil-app-server was executed) /.anvi-data/db/postmaster.opts

However, apparently, there is neither a ʻarticles table nor acategories` table that the app should need. anvil_db_tables.png

For the time being, if you look at the contents of the existing table, you will find the information of the table created by the application in the ʻapp_storage_tables` table. anvil_db_app_storage_tables.png

Also, looking at creating data using the todo app that can be created with the create-anvil-app command, it turns out that data has been added to the ʻapp_storage_data` table. anvil_db_app_storage_tables.png

What does that mean? From the above,

--Table information used by the app is stored in JSON format in the ʻapp_storage_tables table. --When accessing data from the app, access the JSON format data in the ʻapp_storage_data table based on the information in the ʻapp_storage_tables` table.

From the point of view that the data layer and the logic layer can be matched no matter what app you make, it is not unthinkable to use a meta table, but it is a mechanism that frustrates the hearts of amateurs.

Others When I was able to see what kind of data management it was, I went back to Anvil's site and downloaded the data in order to import the data. However, the downloaded data cannot be easily imported. In the case of the `categories` table of News Aggrigator this time,
ID name
[65114][57547127] entertainment
[65114][57547131] business
[65114][57547132] travel
[65114][57547134] sport

You have to write the JSON format data in a form that is consistent with the meta table of the local DB.

  • The ID column is "probably" the information when the data is on the server hosted by Anvil, so it doesn't seem to make much sense in the local DB. Intuitively, I think it's about table ID and row ID.

Postscript I imagine that if it is a paid plan, it will be flexible to some extent, and there will be appropriate advice and tools to use, but it is a little difficult to make an application with a free plan and host it on your own. think. Well, if you have a paid plan, you can set your own domain, so it's probably the main way to use it.

Recommended Posts

About data management of anvil-app-server
Numerical summary of data
About all of numpy
About assignment of numpy.ndarray
About MultiIndex of pandas
About variable of chainer
Preprocessing of prefecture data
Selection of measurement data
About the inefficiency of data transfer in luigi on-memory
About max_iter of LogisticRegression () of scikit-learn
Data handling 3 (development) About data format
Tuning experiment of Tensorflow data
About Japanese path of pyminizip
About the ease of Python
Visualization of data by prefecture
About various encodings of Python 3
About all of numpy (2nd)
Fourier transform of raw data
Average estimation of capped data
About cost calculation of MeCab
About approximate fractions of pi
A story about clustering time series data of foreign exchange
About HOG output of Scikit-Image
About the features of Python
Probability prediction of imbalanced data
Development of WEB application using Django [Add data from management screen]
About Boxplot and Violinplot that visualize the variability of independent data
About learning method with original data of CenterNet (Objects as Points)
About Deep Learning (DNN) Project Management
About the return value of pthread_mutex_init ()
About the basic type of Go
Memory-saving matrix conversion of log data
About the upper limit of threads-max
About time series data and overfitting
About circular crossover of genetic algorithms
Differentiation of time series data (discrete)
10 selections of data extraction by pandas.DataFrame.query
Animation of geographic data by geopandas
Recommendation of data analysis using MessagePack
About the behavior of yield_per of SqlAlchemy
Time series analysis 3 Preprocessing of time series data
About import error of PyQt5.QtWidgets (Anaconda)
About the size of matplotlib points
About color halftone processing of images
About the basics list of Python basics
Data handling 2 Analysis of various data formats
Try to get the road surface condition using big data of road surface management