Docs: Table
Return to the docs
Properties:
-> client : Client object of the database wich this table is stored in;
-> id : this is the table id, each table have an unique id that's used to identificate each one on the Client obj;
-> name : this is the table name;
-> columns : returns a list of columns in this table;
-> rows : return a list of Row objects stored on this table;
Methods:
-> get_rows(cols) : returns a list of Row objects that matches with the value of parameters passed on the function. Example:
rows = table.get_rows(name="foo")
for row in rows:
print(row.name)
""" output:
foo
foo
foo
...
"""
-> get_first(cols) : it's like "get_rows", but this one returns the first Row object that matches with the parameters passed;
-> add_row(cols) : adds a row to the table based on parameters passed on the function. Example:
table.add_row(name="foo", id=1)
Return: Row
-> remove_row(row_id: int) : removes a row based on id;
-> add_column(cname: str, ctype) : add a column to the table with a given name and type;
-> remove_column(cname: str) : remove a column based on name;
-> save() : commits the table to the table;
-> delete() : deletes the entire current table from the database; (make sure that you won't use any references of this table, otherwise it will result in a TableNotFoundError);