AxterDB Client#
- class axterdb.Client(*, name, key, host, show_keys=False)[source]#
- Parameters:
name (
str) –key (
str) –host (
str) –show_keys (
bool) –
- await connect()[source]#
This function is a coroutine.
Connects to the database, checks if everything is correct.
- await create_table(table, **columns)[source]#
This function is a coroutine. Creates a table on the database
- Parameters:
table (
str) – The table name to create.**columns – Additional arguments are used as columns for the table.
- Returns:
Returns True if function was executed sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
UnAcceptedType – Invalid row type.
InvalidTable – Table not provided.
InvalidRows – Rows not provided.
TableAlreadyExists – Table with that name already exists.
- await get(table, amount=None, **kwargs)[source]#
This function is a coroutine. Get data from a table
- Parameters:
table (
str) – The table to get data from.amount (
str) – The amount of data to get.**kwargs – Additional arguments are used as condition arguments (WHERE in SQL)
- Returns:
Returns a list of lists containing data, or an empty list if no data was found.
- Return type:
list- Raises:
NotConnected – Not connected to the database.
- await insert(table, **data)[source]#
This function is a coroutine. Insert data into a table
- Parameters:
table (
str) – The table to insert data to.**data – Additional arguments are used as data to insert.
- Returns:
Returns True if query executed sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
InvalidColumn – Invalid column provided.
- await delete(table, **data)[source]#
This function is a coroutine. Deletes data from a table
- Parameters:
table (
str) – The table to delete data from.**data – Additional arguments are used as data to delete.
- Returns:
Returns True if query executed sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
- await delete_table(table)[source]#
This function is a coroutine. Deletes a table
- Parameters:
table (
str) – The table to delete.- Returns:
Returns True if query executed sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
- class axterdb.AdminClient(*, name, key, host, show_keys=False)[source]#
- Parameters:
name (
str) –key (
str) –host (
str) –show_keys (
bool) –
- await create_user(name, admin=False)[source]#
This function is a coroutine. Create a user.
- Returns:
Generated key for the created user.
- Return type:
str- Raises:
NotConnected – Not connected to the database.
- Parameters:
name (
str) –admin (
bool) –
- await delete_user(key)[source]#
This function is a coroutine. Delete a user.
- Returns:
Returns True if user was deleted sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
- Parameters:
key (
str) –
- await check_table(table)#
This function is a coroutine. Check if a table exists
- Parameters:
table (
str) –- Returns:
Returns True if table exists, else False
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
InvalidKey – Key is invalid.
- await connect()#
This function is a coroutine.
Connects to the database, checks if everything is correct.
- await create_table(table, **columns)#
This function is a coroutine. Creates a table on the database
- Parameters:
table (
str) – The table name to create.**columns – Additional arguments are used as columns for the table.
- Returns:
Returns True if function was executed sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
UnAcceptedType – Invalid row type.
InvalidTable – Table not provided.
InvalidRows – Rows not provided.
TableAlreadyExists – Table with that name already exists.
- await delete(table, **data)#
This function is a coroutine. Deletes data from a table
- Parameters:
table (
str) – The table to delete data from.**data – Additional arguments are used as data to delete.
- Returns:
Returns True if query executed sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
- await delete_table(table)#
This function is a coroutine. Deletes a table
- Parameters:
table (
str) – The table to delete.- Returns:
Returns True if query executed sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
- await get(table, amount=None, **kwargs)#
This function is a coroutine. Get data from a table
- Parameters:
table (
str) – The table to get data from.amount (
str) – The amount of data to get.**kwargs – Additional arguments are used as condition arguments (WHERE in SQL)
- Returns:
Returns a list of lists containing data, or an empty list if no data was found.
- Return type:
list- Raises:
NotConnected – Not connected to the database.
- await get_all_tables()#
This function is a coroutine. Get all tables of the database
- Returns:
Returns a list of table names
- Return type:
list- Raises:
NotConnected – Not connected to the database.
InvalidKey – Key is invalid.
- await insert(table, **data)#
This function is a coroutine. Insert data into a table
- Parameters:
table (
str) – The table to insert data to.**data – Additional arguments are used as data to insert.
- Returns:
Returns True if query executed sucessfully.
- Return type:
bool- Raises:
NotConnected – Not connected to the database.
InvalidColumn – Invalid column provided.