No such app table when connecting with Uplink

I send file to jupyter and receive a dataframe as a output.
Dataframe might have different columns, so I want to be flexible here.

I created new table in Data tables with name “osago1”. No columns. Ticked “columns autocreate”.
And just in case provide permission to read and write to forms.

It shows python name for table: app_tables.osago1

When I try to use the following code on jupyter:
for d in final_df.to_dict(orient=“records”):
# d is now a dict of {columnname -> value} for this row
# We use Python’s **kwargs syntax to pass the whole dict as
# keyword arguments
app_tables.osago1.add_row(**d)

I get the following error:
AttributeError: No such app table: ‘osago1’
at /home/vs/anaconda3/lib/python3.7/site-packages/anvil/tables/init.py, line 20

Could you please help how to publish dataframe to a grid.

Hello and welcome,

Are you connecting to your app using Uplink?

I’m just wondering if you are connecting to a different app accidentally (one without that table).

Is it possible for you to share a clone link of your app so we can take a look (do not share if there is sensitive data)? Click the :gear: in the IDE and follow the instructions if you are able to share a clone.

I have no problems with uplink, when I get text and print it in a label.
https://anvil.works/build#clone:XBCQLJZWBHWTQROP=GPNUIWY7M2IVEIJEE2CLJTX6

I also see the the problem, when I try run
https://anvil.works/build#app:DV5M7OHCKVU2AYO2
which was mentioned in Importing existing data into Data Table
ImportError: No module named pandas

When I clone the app and try adding rows with a list of dicts, everything works as expected:

ds=[{'a': 1, 'b': 2}, {'a': 11, 'b': 21}, {'a': 11, 'b': 22}]
for d in ds:
  app_tables.osago1.add_row(**d)
 
Anvil server output: Automatically creating column "a" (number)
Anvil server output: 
Anvil server output: Automatically creating column "b" (number)
Anvil server output: 

If you have not already double checked your uplink key, please do so (although I think you have already)

1 Like

This is a different error than the original post and means you need to switch to a different Python runtime if you are importing Pandas in a server module. Try switching to the full Python 2.7 or Python 3.6 runtimes (see top right hand corner of the server modules).

1 Like

I checked your code. When I run it from server side, then it is OK. When I run it from jupyter, I still get the error.

I’m running it from an Uplink script, which I assume is how you are running it from Jupyter (with Uplink).

You are using Uplink right?

Could you maybe share a fuller snippet of your Jupyter code?

1 Like
#Anvil Uplink server definition

import anvil.media
import csv
import json
import anvil.tables
from anvil.tables import app_tables
@anvil.server.callable
def extract_xlsdata(file):
    with anvil.media.TempFile(file) as filename:
        #for d in final_df.to_dict(orient="records"):
          # d is now a dict of {columnname -> value} for this row
          # We use Python's **kwargs syntax to pass the whole dict as
          # keyword arguments
        #  app_tables.osago1.add_row(**d)
        ds=[{'a': 1, 'b': 2}, {'a': 11, 'b': 21}, {'a': 11, 'b': 22}]
        for d in ds:
           app_tables.osago1.add_row(**d)
        return finalt
  
#Required, so the web app could call the function
anvil.server.wait_forever()

Just trying it without the with statement works for me. Could you also try it without the with statement for now?

For example:

@anvil.server.callable
def simple_test_function():

   ds=[{'a': 1, 'b': 2}, {'a': 11, 'b': 21}, {'a': 11, 'b': 22}]
   for d in ds:
      app_tables.osago1.add_row(**d)

Still the same error:
AttributeError: No such app table: ‘osago1’ at /home/vs/anaconda3/lib/python3.7/site-packages/anvil/tables/init.py, line 20 called from , line 9 called from [Form1, line 19](javascript:void(0))

Can you clone this, connect to it with the Uplink key for this app, and run the function I have above.

https://anvil.works/build#clone:6FEYQ4VBJMZYY2W6=DDVS2AQBWXD6UJXN7CW5LZL5

3 Likes

I couldn’t run you app on free plan, so I commented #anvil.server.call(‘say_hello’, ‘asdf’)

And error is gone!

So everything is working for you now?

If everything is working, I am still left wondering if the original Uplink key was simply pointing to another app, or if the table name in the app was slightly different. That’s all I can think of.

1 Like

Thanks a lot!
Yes, now it is adding data to table. In the original app: Uplink key was correct (it worked without access to the table) and table name was correct (I tried several table names and created new tables).
So, I guess the system decided not to mess with you :slight_smile:

Btw, what is the fasted way to put this data table to grid, so I would not add columns names manually. Something similiar to df.head(10) in python.

1 Like

Are you asking how to display the data table on the client-side (e.g., using the DataGrid component)?

Or, are you asking how to print out the “head” of the data table in the output window?

Client side: Data Grid component.

I would suggest that you go through the DataGrid tutorials. They are very good.

For example, here is a good starting point:
https://anvil.works/learn/tutorials/data-grids/getting-started

1 Like

Thanks. Already doing that!
Thanks again for your help.

You’re welcome.

If you run into issues after having gone through the tutorials, don’t hesitate to open another topic and we’ll try to help.

2 Likes