def parse_and_execute(self, parsed_args: Dict):
     client = create_client_from_parsed_args(parsed_args)
     table_name = parsed_args['table-name']
     if prompt_confirmation(
             f'Confirm delete table `{table_name}`? The action is irreversible',
             False):
         api.delete_table(client, table_name)
     return 0
 def clean_up():
     delete_table(self.client, rename_table_name)
 def _default_clean_up():
     try:
         delete_table(self.client, self.default_table_name)
     except Exception as e:
         self.logger.error(f"failed to delete table in cleanup: {e}")
 def clean_up():
     delete_table(self.client, copy_table_name)
 def tearDown(self):
     super().tearDown()
     delete_table(self.client, self.default_table_name)
Пример #6
0
import json

# 1. load the data
df = pandas.read_csv("../datasets/invoice-automation/invoice_data.csv")
print("loaded the invoice data.")

# 2. load the database schema
with open("schema.json") as f:
    schema = json.load(f)
print("loaded the invoice schema from schema.json.")

# 3. create the Aito table
aito_instance_url = os.environ.get('AITO_INSTANCE_URL')
aito_api_key = os.environ.get('AITO_API_KEY')

aito_client = AitoClient(instance_url=aito_instance_url, api_key=aito_api_key)
delete_table(client=aito_client, table_name='invoice_data')
create_table(client=aito_client, table_name='invoice_data', schema=schema)
print("created the aito database table.")

# 4. convert the dataframe to have correct types
entries = DataFrameHandler().convert_df_using_aito_table_schema(
  df=df,
  table_schema=schema
).to_dict(orient="records")
print("converted the dataframe.")

# 5. upload the entries
upload_entries(aito_client, table_name='invoice_data', entries=entries)
print("uploaded the entries.")
Пример #7
0
 def delete_default_table_and_check(self):
     api.delete_table(self.client, self.default_table_name)
     self.assertFalse(api.check_table_exists(self.client, self.default_table_name))
Пример #8
0
 def clean_up():
     api.delete_table(self.client, self.default_table_name)
     api.delete_table(self.client, copy_table_name)
     api.delete_table(self.client, rename_table_name)