Python Table Data Type with some SQL-like operations.
Project description
Pytql
Python Table Data Type with some SQL-like operations.
Authors
API Reference
Classes
Table / Data
Parameter | Type | Description |
---|---|---|
headers |
List , Optional |
A collection of table headers |
data |
List , Optional |
Data to be populated in the table |
header_color |
Color , Optional |
Color for the header |
row_color |
Color , Optional |
Color for the rows |
table_color |
Color , Optional |
Color for the table design |
Table Methods
draw_table(data)
Parameter | Type | Description |
---|---|---|
data |
List |
Required. Table data to be drawn |
return: None
add_row(data)
Parameter | Type | Description |
---|---|---|
row |
List |
Required. Row to be added to table |
position |
Integer |
Position of the new row |
return: None
update(column)
Parameter | Type | Description |
---|---|---|
column |
String |
Required. Column to be updated |
return: Table | None
where(value, updated_value)
Parameter | Type | Description |
---|---|---|
value |
String |
Current value in table |
updated_value |
String |
New value to replace old value |
return: None
query()
return: Data
get_data()
return: List
Data Methods
filter_by(column)
Parameter | Type | Description |
---|---|---|
column |
String |
Required. Column to be filtered |
return: Data | None
greater_than(value)
Parameter | Type | Description |
---|---|---|
value |
String |
Required. Value to be filtered by |
return: Data | None
less_than(value)
Parameter | Type | Description |
---|---|---|
value |
String |
Required. Value to be filtered by |
return: Data | None
equals(value)
Parameter | Type | Description |
---|---|---|
value |
String |
Required. Value to be filtered by |
return: Data | None
end_query()
return: List
Installation
Install pytql with pip3
pip3 install pytql==[version]
current version = 0.0.3
Usage/Examples
from pytql import Table, Color
if __name__ == '__main__':
headers = ['First Name', 'Last Name', 'Age', 'Count']
list_data = [
["Richard", "Quaicoe", 23, 243],
["Mike", "Kuam", 33, 123],
["Roynam", "Skim", 13, 56],
["Leon", "Santa", 29, 23],
["Geroge"]
]
dict_data = {
'First Name': ['Richard', 'Mike', 'Roynam', 'Leon', 'George'],
'Last Name': ['Quaicoe', 'Kuam', 'Skim', 'Santa'],
'Age': [23, 33, 13, 29],
'Count': [243, 123, 56, 23]
}
# Example with passing dictionary data
table = Table(data=dict_data, header_color=Color.cyan, row_color=Color.green, table_color=Color.blue)
# Example with passing list data
table1 = Table(headers=headers, data=list_data, header_color=Color.cyan, row_color=Color.green, table_color=Color.blue)
# You can use table (for dict type) or table1 (for list type)
t_data = table.get_data()
table.draw_table(t_data)
table.add_row(["Mamba", "Avatar", 32, 43], position=3)
table.draw_table(t_data)
t1 = table.query().filter_by("First Name").equals("Richard").filter_by("Count").greater_than("50").end_query()
table.draw_table(t1)
table.update("Age").where("32", "67")
table.draw_table(t_data)
t1 = table.query().filter_by("Age").greater_than("50").end_query()
table.draw_table(t1)
table.add_row(["Clean", "Quain", 32, 43], position=2)
table.draw_table(t_data)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytql-0.0.3.tar.gz
(6.9 kB
view hashes)
Built Distribution
pytql-0.0.3-py3-none-any.whl
(7.0 kB
view hashes)