コード例 #1
0
 def upload_by_batch_step_generator(self, start, end):
     entries = self.generator_for_test(start, end)
     api.upload_entries(
         self.client,
         table_name=self.default_table_name,
         entries=entries,
         batch_size=2,
         optimize_on_finished=False)
コード例 #2
0
 def parse_and_execute(self, parsed_args: Dict):
     client = create_client_from_parsed_args(parsed_args)
     table_name = parsed_args['table-name']
     table_entries = load_json_from_parsed_input_arg(parsed_args['input'])
     api.upload_entries(client,
                        table_name=table_name,
                        entries=table_entries)
     return 0
コード例 #3
0
 def upload_by_batch_step(self, start, end):
     entries = [{'id': idx, 'name': 'some_name', 'amount': idx} for idx in range(start, end)]
     api.upload_entries(
         self.client,
         table_name=self.default_table_name,
         entries=entries,
         batch_size=2,
         optimize_on_finished=False)
コード例 #4
0
    def test_upload_and_delete_entries(self):
        self.addCleanup(self.delete_default_table_and_check)

        self.create_default_table_and_check()
        entries = [{'id': idx, 'name': 'some_name', 'amount': idx} for idx in range(10)]
        api.upload_entries(client=self.client, table_name=self.default_table_name, entries=entries)

        instance_entries = api.query_entries(self.client, self.default_table_name)
        self.assertEqual(instance_entries, entries)

        api.delete_entries(client=self.client, query={'from': self.default_table_name, 'where': {'id': {'$gte': 5}}})
        instance_entries = api.query_entries(self.client, self.default_table_name)
        self.assertEqual(instance_entries, entries[:5])
コード例 #5
0
 def upload_entries_to_table(self):
     upload_entries(self.client, self.default_table_name, self.default_entries)
コード例 #6
0
    'Teach Aito?',
    'Would you like to upload this invoice to Aito?',
    parent=parent)


def read_field(field_element):
    return driver.find_element_by_name(field_element).get_attribute('value')


if teach == 'yes':
    # Figure out the next invoice id
    inv_id = \
      search(db, {
          "from": "invoice_data",
          "orderBy" : "Inv_Id"
      })["hits"][0]["Inv_Id"]+1
    # This is the new invoice entry
    entry = {
        "Item_Description": read_field("Field1"),
        "Product_Category": read_field("Field2"),
        "GL_Code": read_field("Field3"),
        "Vendor_Code": read_field("Field4"),
        "Inv_Amt": 1,
        "Inv_Id": inv_id
    }
    # upload the data and inform the user, it's done
    upload_entries(db, table_name='invoice_data', entries=[entry])
    messagebox.showinfo('Done.',
                        f"Inventory item {inv_id} was added.",
                        parent=parent)
コード例 #7
0
ファイル: prepare.py プロジェクト: AitoDotAI/aito-examples
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.")