Limitation on insert rows - deleting rows using python

I am making a python script that is doing some calculations and the end result shoud be inserting about 10 000 - 15 000 rows. I am using the base.batch_append_rows in order to insert the data in one call and when I run the script I get an
error Exceed the operation limit on rows. I have read in the documentation about the system limits
that the maximum insert is 1000 requests in a single call ( Max. number of rows appending in a single call). Is there a possibility to change this limitation since I use SeaTable Enterprise on-premise? If not
what can I do i order to insert the all neceseray data in one call? (I am relatively new at using Python)

Also do you have an example on how I can delete some specific rows using loop, the data that i get is getting the list of rows from table and specific view (the existing example for delete row is not suitable for my case).

You can insert rows in a loop, in each iteration, you insert 1000 rows.

You can use SQL interface to get the list of rows to delete and then delete the rows with there row IDs.

When You mean each iteration you mean calling the script each time I insert 1000 rows? I did not understood that part . Here is the code that I wrote (do you have some suggestions, my need is to the calculation in one call)

#Autorization
from seatable_api import Base, context
from seatable_api.constants import ColumnTypes
base = Base(context.api_token, context.server_url)
base.auth()
rowpepin = base.list_rows('S_PEOPLE_INVOLMENT', view_name='TeamClientRelationsP', order_by=None, desc=False, start=None, limit=None)
rowdate  = base.list_rows('S_DATE', view_name='DefaultView', order_by=None, desc=False, start=None, limit=None)
row = []


for x in rowpepin:
  for y in rowdate:
    if x.get('Office') == 'Switzerland':
      Engagment = y.get('WorkSWnumber');
      Work      = y.get('WorkSWnumber');
    elif x.get('Office') == 'Serbia':
      Engagment = y.get('WorkSRBnumber');
      Work      = y.get('WorkSRBnumber');
    else:
      Engagment = y.get('WorkBihRsNumber');
      Work      = y.get('WorkBihRsNumber');
    if y.get('Date') >= x.get('DateFrom') and y.get('Date') < x.get('DateTo') and Engagment!=0:
      Engagment = x.get('EngagmentMath');
    else:
      Engagment = 0;
    if x.get('Bilable') == 'Chargeable':
      EngagmentC = Engagment;
      EngagmentN = 0;
    else:
      EngagmentC = 0;
      EngagmentN = Engagment;
    row.append({'Office':x.get('Office')})
base.batch_append_rows('C_INVOLMENT_V2',  row)

About the delete, a try in the next whay (aslo thought do on how you suggested) but when I run the script the rows whont delete

#Autorization
from seatable_api import Base, context
from seatable_api.constants import ColumnTypes
base = Base(context.api_token, context.server_url)
base.auth()
string3 = 'Select _id from C_INVOLMENT'; 
cinvol    = base.query(string3);
for m in cinvol:
  base.delete_row('C_INVOLMENT', m.get('_id'))

After some days of investigation based on the given hints, I managed to solve both my problem.
Example of the code:
#Autorization
from seatable_api import Base, context
from seatable_api.constants import ColumnTypes
base = Base(context.api_token, context.server_url)
base.auth()
reprows = []
xx = 0
#Delete rows
while xx < 3:
rinvol = base.list_rows(‘R_CAPACITY_V3’, view_name=‘TeamClientRelations’, order_by=None, desc=False, start=None, limit=None)
for z in rinvol:
reprows.append(z.get(‘_id’))
base.batch_delete_rows(‘R_CAPACITY_V3’, reprows)
xx = xx + 1
#Calculate and insert data
row = []
rows = []
string = ‘Select Team, Name, Office, MonthNumber, Month, Year, sum(EngagmentC) as EngagmentC, sum(EngagmentN) as EngagmentN from C_INVOLMENT where Team = :1 group by Team, Name, Office, MonthNumber, Month, Year limit 10000’
rowdate = base.list_rows(‘C_MONTH_YEAR_WORKDAY’, view_name=‘DefaultView’, order_by=None, desc=False, start=None, limit=None)
query = string.replace(‘:1’,“‘Team Client Relations’”)
cinvol = base.query(query);
for x in cinvol:
for y in rowdate:
if x.get(‘Office’) == ‘Switzerland’:
if x.get(‘MonthNumber’) == y.get(‘MonthNumber’) and x.get(‘Year’) == y.get(‘Year’):
WorkDays = y.get(‘WorkDaySW’)
elif x.get(‘Office’) == ‘Serbia’:
if x.get(‘MonthNumber’) == y.get(‘MonthNumber’) and x.get(‘Year’) == y.get(‘Year’):
WorkDays = y.get(‘WorkDaySRB’)
else:
if x.get(‘MonthNumber’) == y.get(‘MonthNumber’) and x.get(‘Year’) == y.get(‘Year’):
WorkDays = y.get(‘WorkDayBihRs’)
row.append({‘Team’: x.get(‘Team’),‘Name’: x.get(‘Name’), ‘MonthNumber’: x.get(‘MonthNumber’), ‘Month’: x.get(‘Month’), ‘Year’: x.get(‘Year’), ‘Chargeable’: x.get(‘EngagmentC’), ‘NotChargeable’: x.get(‘EngagmentN’), ‘WorkingDays’: WorkDays})
x = 0
size = len(row)
for r in row:
rows.append(r)
x = x + 1
size = size - 1
if x == 1000:
base.batch_append_rows(‘R_CAPACITY_V3’, rows)
rows = []
x = 0
if size == 0:
base.batch_append_rows(‘R_CAPACITY_V3’, rows)

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.