zbpy package

Submodules

zbpy.client module

class zbpy.client.NewAccount(shell=None, **kwargs)
createaccount(line)
magics = {'cell': {}, 'line': {'createaccount': 'createaccount'}}
registered = True
class zbpy.client.ZetabaseClient(uid)

An instance of a Zetabase client.

__Init__ Parameters:
uid: string
add_permission(table_id, perm, table_owner_id=self.user_id)

Adds a new permission to an existing table.

Parameters:
table_id: string
perm: PermEntry
table_owner_id: string (default=self.user_id)
Returns:
None (if no error else raises exception)
auth_login_jwt()

Uses jwt to login a ZetabaseClient that is already connected.

Returns:
None (if no error else raises exception)
check_ready()

Checks to see if the ZetabaseClient is ready to make a request.

Returns:
boolean
check_version()

Checks to see if Client version is compatible.

Returns:
boolean, zbpprotocol_pb2.VersionDetails
confirm_new_sub_user(subuser_id, verification_code)

Confirms the creation of a new subuser using the subuser’s verification code (sent to phone).

Parameters:
subuser_id: string
verification_code: string
Returns:
None (if no error else raises exception)
connect()

Establishes a connection between the Zetabase client to the server.

create_table(table_id, data_type, indexed_fields=[], perms=[], allow_jwt=True)

Creates a table with given attributes.

Parameters:
table_id: string
data_type: zbprotocol_pb2.TableDataFormat
indexed_fields: list of IndexedField (default=[])
perms: list of PermEntrys (default=[])
allow_jwt: boolean (default=True)
Returns:
None (if no error else raises exception)
delete_key(table_id, key, table_owner_id=self.user_id)

Deletes the specified key.

Parameters:
table_id: string
key: string
table_owner_id: string (default=self.user_id)
Returns:
None (if no error else raises exception)
delete_table(table_id, table_owner_id=self.user_id)

Deletes the specified table.

Parameters:
table_id: string
table_owner_id: string (default=self.user_id)
Returns:
None (if no error else raises exception)
get(table_id, keys, table_owner_id=self.user_id, max_item_size=1000)

Returns items from the specified table with the specified keys.

Parameters:
table_id: string
keys: list of strings
table_owner_id: string (default=self.user_id)
max_item_size: integer (default=1000)
Returns:
GetPages
get_all(table_id, table_owner_id=self.user_id)

Returns all items from the specified table.

Parameters:
table_id: string
table_owner_id: string (default=self.user_id)
Returns:
GetPages
get_sub_identities()

Returns all of the subusers of the ZetabaseClient.

Returns:
zbprotocol_pb2.SubIdentitiesList.subIdentities
grpc_stub()
Returns:
zbprotocol_pb2.ZetabaseProviderStub
id()

Gives the ZetabaseClient’s user id.

Returns:
string
list_keys(table_id, table_owner_id=self.user_id)

Lists the keys for the specified table.

Parameters:
table_id: string
table_owner_id: string (default=self.user_id)
Returns:
GetPages
list_keys_with_pattern(table_id, pattern, table_owner_id=self.user_id)

Lists keys that begin with a certain prefix.

Parameters:
table_id: string
pattern: string
table_owner_id: string (default=self.user_id)
Returns:
GetPages
list_tables(return_json=False)

Lists all table names associated with your Zetabase id. If return_json is set to True a list of Json objects will be returned that contain all information about the configurations of a every table.

Parameters:
return_json: boolean (default=False)
Returns:
list of strings
login_jwt(login_id, password)

Connects to Zetabase and logs in using jwt.

Parameters:
login_id: string
password: string
new_sub_user(handle, email, mobile, password, signup_code, group_id)

Creates a new subuser and returns the subuser’s id.

Parameters:
handle: string
email: string
mobile: string
password: string
signup_code: string
group_id: string
Returns:
string, PrivateKey, PublicKey
put_data(table_id, key, value, overwrite=False, table_owner_id=self.user_id)

Put the specified data into the specified table with the given key.

Parameters:
table_id: string
key: string
value: bytes
overwrite: boolean (default=True)
table_owner_id: string (default=self.user_id)
Returns:
None (if no error else raises exception)
put_dataframe(table_id, dataframe, df_key, overwrite=False, table_owner_id=self.user_id)

Put pandas DataFrame into a json table with a specified key that will designate all entries of the dataframe.

Parameters:
table_id: string
dataframe: pandas.DataFrame
df_key: string
overwrite: boolean (default=False)
table_owner_id: string (default=self.user_id)
Returns:
None (if no error else raises exception)
put_dataframe_new_table(table_id, dataframe, df_key, perms=[], specify_fields=None, allow_jwt=True)

Creates a new table with indexed fields to match the names and types of the dataframe’s columns. By default, all columns will be indexed, but a subset can be specified by listing the names of the columns in the ‘specify_fields’ parameter.

Parameters:
table_id: string
dataframe: pandas.DataFrame
df_key: string
perms: list of PermEntry objects (default=[])
specify_fields: list of strings (default=All columns)
allow_jwt: boolean (default=True)
Returns:
None (if no error else raises exception)
put_multi(table_id, keys, values, overwrite=False, table_owner_id=self.user_id)

Put multiple pieces of data into a table with the specified keys.

Parameters:
table_id: string
keys: list of strings
values: list of bytes
overwrite: boolean (default=False)
table_owner_id: string (default=self.user_id)
Returns:
None (if no error else raises exception)
put_np_array(table_id, array, key, overwrite=False, table_owner_id=self.user_id)

Put numpy array into a table with the given key.

Parameters:
table_id: string
array: np.array
key: string
overwrite: boolean (default=False)
table_owner_id: string (default=self.user_id)
Returns:
None (if no error else raises exception)
query(table_id, qry, table_owner_id=self.user_id)

Queries keys based on the specified query and table.

Parameters:
table_id: string
qry: Query type object
table_owner_id: string (default=self.user_id)
Returns:
GetPages
query_data(table_id, qry, table_owner_id=self.user_id)

Queries data based on the specified query and table.

Parameters:
table_id: string
qry: Query type object
table_owner_id: string (default=self.user_id)
Returns:
GetPages
set_id_key(priv, pub)

Sets the private and public keys of the ZetabaseClient to priv and pub respectively.

Parameters:
priv: fastecdsa.PrivateKey
pub: fastecdsa.PublicKey
set_id_password(login_id, pwd)

Sets the login_id and password of the ZetabaseClient.

Parameter:
login_id: string
pwd: string
set_parent(id)

Sets the parent_id of the ZetabaseClient to id.

Parameters:
id: string.
setup_ecdsa(priv_filepath, pub_filepath)

Connects to Zetabase, imports the public and private key, and sets them so the user is ready to make requests.

Parameters:
priv_filepath: string (file path to your private key)
pub_filepath: string (file path to your private key)
zbpy.client.import_key(filepath, public, curve=P256)

Returns the keys located at the specified filepath.

Parameters:
filepath: string
public: boolean
curve: fastecdsa.curve (default=P256)
Returns:
fastecdsa.key (public or private)

zbpy.indexedfieldentity module

class zbpy.indexedfieldentity.IndexedField(field_name, index_type, lang_code='')

An instance of an indexed field. Indexed fields are used to query data as well as to set constraints on tables.

__Init__ Parameters:
field_name: string
index_type: zbprotocol_pb2.QueryOrdering
lang_code: string
set_language_code(code)

Sets the language code of the IndexedField.

Parameters:
code: string

zbpy.pagination module

class zbpy.pagination.GetPages(f)

Data requested from Zetabase is returned in a pagination handler. The following methods give different options for extracting the data.

data()

Returns the current page of data.

data_all()

Returns all pages of data.

get_first_n_pages(n)

Returns the first n pages of data.

Parameters:
n: integer
keys()

Returns the keys of the current page of data.

keys_all()

Returns all keys.

next()

Moves the cursor to the next page of data if there is one.

return_bytes()

Will make items return as bytes when the GetPages object is iterated through.

return_pretty()

Will make items return as Python dictionaries when the GetPages object is iterated through.

to_dataframe()

Returns the data in the GetPages as a pandas DataFrame.

to_numpy_arrays()

Returns the data in the GetPages as a matrix of numpy arrays.

zbpy.permissionentity module

class zbpy.permissionentity.PermConstraint(field, req_value='@uid')

A constraint placed on a permission that must also be satisfied in order for the permission to apply.

__Init__ Parameters:
field: string
req_value: string (default='@uid')
   Built-in req_values:
      '@uid' -> UID
      '@time' -> TIME
      '@order' -> ORDER
      '@random' -> RANDOM
class zbpy.permissionentity.PermEntry(level, audience_type, audience_id='')

A permission that controls who can read, write, delete, or have administrative powers on a table.

__Init__ Parameters:
level: zbprotocol_pb2.PermissionLevel
audience_type: zbprotocol_pb2.PermissionAudienceType
audience_id: string (default='')
add_constraint(c)

Adds constraint to the PermEntry.

Parameters:
c: PermConstraint

zbpy.queries module

class zbpy.queries.Field(field)

An instance of this class allows you to query your Zetabase table by field.

__Init__ Parameters:
field: string

zbpy.util module

zbpy.util.new_account_interactive()
zbpy.util.test_zbpy()

zbpy.zbprotocol_pb2 module

Enums
zbpy.zbprotocol_pb2.PermissionAudienceType

Options for who a specific permission applied to a table pertains to.

Enumerators:
INDIVIDUAL
USER
PUBLIC
zbpy.zbprotocol_pb2.PermissionLevel

Options for what type of permission is applied to a table.

Enumerators:
NONE
READ
APPEND
DELETE
ADMINISTER
zbpy.zbprotocol_pb2.QueryOrdering

Options for the types of an indexed field.

Enumerators:
LEXICOGRAPHIC
REAL_NUMBERS
INTEGRAL_NUMBERS
FULL_TEXT
zbpy.zbprotocol_pb2.TableDataFormat

Options for the type of a table.

Enumerators:
BINARY
PLAIN_TEXT
JSON
Messages
zbpy.zbprotocol_pb2.VersionDetails
Attributes:
serverVersion: string
clientVersion: string
minClientVersion: string
zbpy.zbprotocol_pb2.SubIdentitiesList
Attributes:
subIdentities: repeated NewSubIdentityRequest
zbpy.zbprotocol_pb2.NewSubIdentityRequest
Attributes:
id: string
name: string
email: string
mobile: string
loginPassword: string
pubKeyEncoded: string
signupCode: string
groupId: string