SQLTable#
- class dbastable.SQLTable(db, name)#
Bases:
objectHandle an SQL table operations interfacing with the DB.
- Parameters:
- dbSQLDatabase
The parent database object.
- namestr
The name of the table in the database.
Attributes Summary
Get the column names of the current table.
Get the database name.
Get the name of the table.
Get the values of the current table.
Methods Summary
add_column(name[, data])Add a column to the table.
add_rows(data[, add_columns])Add a row to the table.
as_table()Return the current table as an
Tableobject.delete_column(column)Delete a given column from the table.
delete_row(row)Delete all rows from the table.
get_column(column)Get a given column from the table.
get_row(row)Get a given row from the table.
index_of(where)Get the index of the rows that match the given condition.
select(**kwargs)Select rows from the table.
set_column(column, data)Set a given column in the table.
set_row(row, data)Set a given row in the table.
Attributes Documentation
- column_names#
Get the column names of the current table.
- db#
Get the database name.
- name#
Get the name of the table.
- values#
Get the values of the current table.
Methods Documentation
- add_column(name, data=None)#
Add a column to the table. See
add_column.- Parameters:
- namestr
Column name.
- datalist (optional)
- delete_column(column)#
Delete a given column from the table. See
delete_column.- Parameters:
- columnstr
Column name.
- delete_row(row)#
Delete all rows from the table. See
delete_row.- Parameters:
- rowint
Row index.
- get_column(column)#
Get a given column from the table. See
get_column.- Parameters:
- columnstr
Column name.
- Returns:
- res
SQLColumn Column viewer object.
- res
- get_row(row)#
Get a given row from the table. See
get_row.- Parameters:
- rowint
Row index.
- Returns:
- res
SQLRow Row viewer object.
- res
- index_of(where)#
Get the index of the rows that match the given condition. See
index_of.- Parameters:
- wheredict
Dictionary of conditions to select rows. Keys are column names, values are values to compare. If it is a dict of values, all rows equal to the values will be selected. If it is a dict of
Whereobjects, the conditions will be combined with the AND operator. If None, all rows are selected.
- Returns:
- reslist
List of row indexes.
- select(**kwargs)#
Select rows from the table. See
select.- Parameters:
- columnslist (optional)
List of columns to select. If None, select all columns.
- wheredict (optional)
Dictionary of conditions to select rows. Keys are column names, values are values to compare. If it is a dict of values, all rows equal to the values will be selected. If it is a dict of
Whereobjects, the conditions will be combined with the AND operator. If None, all rows are selected.- orderstr (optional)
Column name to order by.
- limitint (optional)
Number of rows to select.
- offsetint (optional)
Number of rows to skip before selecting.
- Returns:
- reslist
List of tuples with the selected rows. Each row values will be returned in a tuple in the same order as the columns.
- set_column(column, data)#
Set a given column in the table. See
set_column.- Parameters:
- columnstr
Column name.
- datalist
List of values to set.