[App Server] Uplink TO a remote App Server

Hi there, this is my first forum post.

I’m trying to move my @https://bazari.anvil.app to a remote server on Digitalocean. So I install Anvil Runtime following this instruction @https://github.com/anvil-works/anvil-runtime/blob/master/doc/getting-started.md … However, because I don’t know Postgresql so I decided to use Anvil to host my DataTables, and use Uplink to interact with data between the Anvil-hosted database “bazari_data” and the Digitalocean-hosted app “bazari” (both client and server codes are on Digitalocean).

So when test uplink to interact with “bazari_data” using a simple Python script following the Quickstart Uplink guide from the doc, it works fine. But when I git and start the app server for bazari, I receive the error:

AttributeError: ‘module’ object has no attribute ‘connect’

despite I have pip install anvil-uplink and import anvil.server anvil.server.connect("my_uplink_key"). What do I do wrong here? I’m on the free plan (so not sure if this is allowed?)

Edit: I believe there is something missing or not right in the App Server. If I run a simple script with python3 hi.py, it would use my anvil-uplink pip but when I anvil-app-server --app bazari it would use the pre-packaged anvil and uplink modules that raise the problem. My Digitalocean is fresh with Python 3.6, but I have installed Python 3.7 and other prerequisites to run App Server.

1 Like

Hello @Thai,

Welcome to the forum!

We have a step-by-step guide in our documentation that shows you how to get your app up and running on DigitalOcean.

The good news is, setting up your app on your Droplet doesn’t require any PostgreSQL. The app server comes with Postgres built in so you don’t need to use the Uplink.

Thanks,
Ryan

4 Likes

Hello Ryan,

Thank you for the respond! Yes I have completed the steps to get anvil on a private VPS without issue. But because I still want to manage the database using Anvil DataTables so that’s why I want to use Uplink. It seems that Uplink is installed separately from the Anvil Runtime when I run pip install anvil-app-server, so anything that got launched with anvil-app-server --app MyApp won’t have Uplink module with connect(). So I think this issue is from the App Server side, which I know will be improved in no time as it’s open-source :slight_smile: So at the moment I will just build a HTTP API on top of my current app so I can still write the back-end and manage the DB on Anvil Cloud while having the front-end on DO :slight_smile:

One other question: previously when I tried to install the complete app with data from the DataTables on DO, I couldn’t figure out how to migrate. Although I have verify that the anvil.yaml file has the DB schema and run anvil-app-server --app MyApp --auto-migrate to launch the app server, the app on DO still didn’t show any data that it supposed to have like the app hosted on Anvil Cloud. Is there anyway I can check if Postgresql actually populates the data (I don’t have much experience with Postgresql or Mysql)? Please let me know any step that I can take to debug this.

Best,

Edit: I’m new to the forum so I’m not sure if I should open a new topic for this question?

Hello @thai,

I’m glad you got your app running.

The Uplink is designed for the specific use case of running code on another machine from the hosted Anvil environment. Using the Uplink to link from your DigitalOcean hosted Anvil app to Anvil’s hosted servers won’t work.

To answer your other question, the --auto-migrate option migrates the data tables schema, not the data.

To get the data from your Anvil hosted app to your DigitalOcean hosted app. You will first need to export the tables to csv. Then you will need to import the data from the CSV into your DigitalOcean Anvil app via a Postgres script. You should be able to do this with a COPY statement.

Thanks,
Ryan

1 Like

I see. Thank you very much @ryan!