Class Methods¶
-
class
dbhelpy.dbhelpy.Helpy(database)[source]¶ -
get_all_asc(table, column)[source]¶ Query your database and sort ascending from a column of choice
- Parameters
table (string) – the table would like to query
column (string) – the column you would like sort by
- Returns
all data from the table sorted by ascending
-
get_all_asc_by(table, sort_column, con_column, condition)[source]¶ Query your database, sort ascending by a column of choice, and specify a condition
Example: get_all_data_by(cars, price, color, red) will return all cars that are red and sort them ascending by price
- Parameters
table (string) – the table would like to query
sort_column (string) – the column you would like sort by
con_column (string) – the column you will apply your condition to
condition (string) – the condition that will determine your filter
- Returns
all data from the table sorted by ascending and a given condition
-
get_all_column(table, column)[source]¶ Retrieve all data from a column.
- Parameters
table (string) – your table
column (string) – your column
- Returns
all data from that column
-
get_all_data(table)[source]¶ Retrieve all data from a table.
- Parameters
table (string) – your table
- Returns
all data from a given table
-
get_all_data_by(table, column, condition)[source]¶ Retrieve all data from a specified table and column filtered by a condition of that column.
Example: To get the number of cars with the color red -> get_all_data_by(‘cars’, ‘color’, ‘red’)
- Parameters
table (string) – your table
column (string) – your column
condition (string) – filter condition
- Returns
all filtered data
-
get_all_dec(table, column)[source]¶ Query your database and sort descending from a column of choice
- Parameters
table (string) – the table would like to query
column (string) – the column you would like sort by
- Returns
all data from the table sorted by descending
-
get_all_dec_by(table, dec_column, con_column, condition)[source]¶ Query your database, sort descending by a column of choice, and specify a condition
Example: get_all_data_by(cars, price, color, red) will return all cars that are red and sort them descending by price
- Parameters
table (string) – the table would like to query
dec_column (string) – the column you would like sort by
con_column (string) – the column you would use your condition for
condition (string) – the condition that will determine your filter
- Returns
all data from the table sorted by descending and a given condition
-
get_cal_column_by(table, column, condition)[source]¶ Adds all integer data from a given column and filter by condition(s)
- Example 1 :
get_cal_column_by(‘table1’, ‘cars’, “blue=’red’”)
- Example 2 :
get_cal_column_by(‘table1’, ‘cars’, “blue=’red’ price=‘1000’”)
- Example 3 :
get_cal_column_by(‘table1’, ‘cars’, “blue=’red’ price=‘1000’ year=‘2020’”)
- Parameters
table (string) – your table
column (string) – your column
condition (string) – your condition (can be multiple, make sure to follow the format in examples)
- Returns
all data from the column of choice
-
get_calc_column(table, column)[source]¶ Adds all integer data from a given column.
- Parameters
table (string) – your table
column (string) – your column
- Returns
the sum of all integer data from your column
-
get_column_by(table, column, condition)[source]¶ Retrieve all data from a column in a table with the ability to sort out conditions from another column or columns.
- Example 1 :
get_column_by(‘table1’, ‘cars’, “blue=”red”“)
- Example 2 :
get_column_by(‘table1’, ‘cars’, “blue=’red’ price=‘1000’”)
- Example 2 :
get_column_by(‘table1’, ‘cars’, “blue=’red’ price=‘1000’ year=‘2020’”)
- Parameters
table (string) – your table
column (string) – your column
condition (string) – your condition (can be multiple, make sure to follow the format in examples)
- Returns
all filtered data
-
get_single_data(table, column, id)[source]¶ Query a single cell in your db
- Parameters
table (string) – the table would like to query
column (string) – the column you would like to point to
id (int) – primary id
- Returns
single cell data from a given id
-
get_single_row(id, table)[source]¶ Get all row data by id
- Parameters
id (int) – id
table (string) – table
- Returns
single row data
-