Accessing another app's database

What I’m trying to do:
I am creating a simple app to add users to my main app.

What I’ve tried and what’s not working:
I have added the main app as a dependency on the UserManager app. I tried to call the main app’s “add_user” server function but I get:

anvil.server.NoServerFunctionError: No server function matching “add_user_test” has been registered

Code Sample:
On the UserManager app:

def create_user_button_click(self, **event_args):
    anvil.server.call('add_user', self.email_text_box.text)

On the main app:

@anvil.server.callable
def add_user(email):
  row = app_tables.users.add_row(
    email=email,
    enabled=True)

I was unsure whether the UseManager app was getting the most upt-to-date code, so I made some changes to a utils function I alredy had coded and called it from the UsersManager app, the code wasn’t getting updated.
Is this a viable way to tackle writing to other app’s databases? How can I get updated code from the dependency import?

Hi @carles,

When you add an app as a dependency, you get that app’s code, but you don’t get its data tables. The code runs with the.

If you want to share data tables (or an entire database) between applications, you can add tables or databases from other apps to the main app:

image

image

However, it looks like your problem might not actually be about accessing other data tables. You say “I tried to call the main app’s “add_user” server function”, but the error message says “No server function matching “add_user_test””. That _test is probably significant – and in any case, if you want help with that piece of code I think we’ll need a bit more explicit clarification of what’s going on!

3 Likes