You are currently viewing the new Anvil Editor Docs.
Switch to the Classic Editor Docs
You are currently viewing the Classic Editor Docs.
Switch to the new Anvil Editor Docs

Connecting to Data Tables

Once you have set up the Anvil Uplink, your local Python code can do anything a Server Module can do. This includes connecting to Data Tables in your Anvil App from your own machine.

Accessing your Data Tables

First, make sure you have enabled the Uplink.

Say, for example, we have a Data Table called ‘people’ that looks like this:

We’ll define a get_people server function to access data in this table, and mark it as @anvil.server.callable. Then, we’ll call this function from our local machine:

# In a script on your own machine (or anywhere)

# Connect the Uplink
import anvil.server
anvil.server.connect("[YOUR UPLINK KEY]")

# import app_tables to access your data tables
from anvil.tables import app_tables

def get_people():
  people =
  for p in people:
  	print(f"This person's name is {p['name']}")

# Call the server function'get_people')


This will produce the following output:

Querying your Data Tables

To use Anvil’s Query Operators, just add this line at the top of your code:

# In a script on your own machine (or anywhere)

import anvil.tables.query as q

Do you still have questions?

Our Community Forum is full of helpful information and Anvil experts.