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 details)
Built Distribution
pytql-0.0.3-py3-none-any.whl
(7.0 kB
view details)
File details
Details for the file pytql-0.0.3.tar.gz
.
File metadata
- Download URL: pytql-0.0.3.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9557413d8b46075b626462e81d760938c9f40295e2580405cb8ee3258848898d |
|
MD5 | e01eca58c3eee4e7f7050f28767bf9f2 |
|
BLAKE2b-256 | 375bed0429688173d1652a4fb66ee2d4ce4762b1d2e4837f40b42f58888c1e49 |
File details
Details for the file pytql-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pytql-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2b97b60f36e03d1a75ca4bfb8ca1d564e8b3e725c369ac9c6cab179f3ebc00b |
|
MD5 | 35543551ad8357fcb1f7a0f826ffd43b |
|
BLAKE2b-256 | 1f1eacf7a3300d8c3d160489b789d80753cc18504fa369e4ff0ff9fd1e604aab |