Skip to main content

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

Release files for tablevalue 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tablevalue 0.2.10
File Size Uploaded
tablevalue-0.2.10.tar.gz 29.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tablevalue 0.2.10
File Interpreter ABI Platform
tablevalue-0.2.10-py3-none-any.whl Python 3 none any Details

Total release size: 72.2 kB

Release files / tablevalue-0.2.10.tar.gz

Download URL tablevalue-0.2.10.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dd02e261464c5a5244e5a521bdf7423b2aeab6769ca36a3e9b8191d2dc637213
BLAKE2b-256 checksum
How to use checksums
8fe753f6dc7df3f5471804780edf58cbb98a1c87afe964b0905be11434c9508b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.1 Windows/10

Release files / tablevalue-0.2.10-py3-none-any.whl

Download URL tablevalue-0.2.10-py3-none-any.whl
Size 42.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fc5f4d76e14023b92d9ac418d318a7bd3b2c3f8de4931d24d2a6b49202a4f42
BLAKE2b-256 checksum
How to use checksums
18532f0132c283118f08abe228ec190fb8c959892ecf10d40e4125bb9721567e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.1 Windows/10

Release history Release notifications | RSS feed

This release

0.2.10 This release

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page