Skip to main content

Table value as 1C:Enterprise

Project description

API Reference

import

  from tablevalue import TableValue

Methods

Method Arguments Description
begin_transaction Setting the transaction start sign
finish_transaction conn.commit()
cancel_transaction conn.rollback()
transaction_is_active Indication of transaction activity
new_row return Row object
new_bulk_insert values_to_bulk fast insert to database
get_data filter_query:dict, sort: str, limit = 100000000 self.cur.fetchall()
get_rows filter_query:dict, sort: str, limit = 100000000 return list of Row objects, Easier to interact with
get_grouped_data columns_to_group: str, columns_to_sum: str, filter_query:dict, sort: str, number_of_rows = 100000000, row_mode=True return grouped data
count the same as "select count(*) from table"
update filter_query:dict, values_query:dict update data
clear delete all data from table
delete filter_query: dict deleting selection data

Usage

1. Get grouped data

  parsed_csv = (('oleg', 'Asbest', 2, 1),
                  ('ivan', 'Asbest', 1, 2),
                  ('nastya', 'Krasnodar', 0, 2),
                  ('Max', 'Asbest', 1, 2),
                  ('Even', 'Krasnodar', 1, 2),
                  ('Rob', 'Krasnodar', 1, 2),
                  ('Mob', 'Ekaterinburg', 1, 2),
                  ('Dick', 'Ekaterinburg', 1, 2),
                  ('Cheize', 'Krasnodar', 1, 2),
                  ('Longard', 'Ekaterinburg', 1, 2),
                  )

    table = TableValue()
    table.columns.add('Name')
    table.columns.add('country')
    table.columns.add('count_of_pets', table.Types.INTEGER)
    table.columns.add('count_of_children', table.Types.INTEGER)

    for data in parsed_csv:
        new_row = table.new_row()
        new_row.Name = data[0]
        new_row.country = data[1]
        new_row.count_of_pets = data[2]
        new_row.count_of_children = data[3]
        new_row.apply_add()

    grouped_county_data = table.get_grouped_data('country', 'count_of_pets, count_of_children')

    for country_data in grouped_county_data:
        message_county = f'{country_data.country}    :   pets: {country_data.count_of_pets}, childrens: {country_data.count_of_children}'
        print(message_county)

Output

Asbest    :   pets: 4, childrens: 5
Ekaterinburg    :   pets: 3, childrens: 6
Krasnodar    :   pets: 3, childrens: 8

2. Get count

print(table.count())

Output

10

3. Get filtered data

asbest = table.get_rows(filter_query={'country': 'Asbest'})
for data in asbest:
    print(f'{data.name}: childrens: {data.count_of_children}. Pets: {data.count_of_pets}')

Output

oleg: childrens: 1. Pets: 2
ivan: childrens: 2. Pets: 1
Max: childrens: 2. Pets: 1

4. Update

table.update(filter_query={'name': 'oleg'}, values_query={'name' : 'OLEG'})
data_oleg = table.get_rows(filter_query={'name': 'OLEG'})
data = data_oleg[0]
print(f'{data.name}: childrens: {data.count_of_children}. Pets: {data.count_of_pets}')

Output

OLEG: childrens: 1. Pets: 2

5. Delete record

table.delete(filter_query={'name':'OLEG'})
data_oleg = table.get_rows(filter_query={'name': 'OLEG'})
data = data_oleg[0]

Output

  data = data_oleg[0]
IndexError: list index out of range

6. Transactions

When there is an active transaction, commit is not performed automatically. The following construction interferes

if not self.transaction_is_active():
    self.conn.commit()

GitHub https://github.com/nixonsis/TableValue

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tablevalue-0.2.10.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tablevalue-0.2.10-py3-none-any.whl (42.9 kB view details)

Uploaded Python 3

File details

Details for the file tablevalue-0.2.10.tar.gz.

File metadata

  • Download URL: tablevalue-0.2.10.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.1 Windows/10

File hashes

Hashes for tablevalue-0.2.10.tar.gz
Algorithm Hash digest
SHA256 dd02e261464c5a5244e5a521bdf7423b2aeab6769ca36a3e9b8191d2dc637213
MD5 e9f422d18e0c1e78424e2b08591e215a
BLAKE2b-256 8fe753f6dc7df3f5471804780edf58cbb98a1c87afe964b0905be11434c9508b

See more details on using hashes here.

File details

Details for the file tablevalue-0.2.10-py3-none-any.whl.

File metadata

  • Download URL: tablevalue-0.2.10-py3-none-any.whl
  • Upload date:
  • Size: 42.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.1 Windows/10

File hashes

Hashes for tablevalue-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 2fc5f4d76e14023b92d9ac418d318a7bd3b2c3f8de4931d24d2a6b49202a4f42
MD5 0ba4a587836481d3bc731674d3ea0822
BLAKE2b-256 18532f0132c283118f08abe228ec190fb8c959892ecf10d40e4125bb9721567e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page