Package: tuser
Ziplit.TuserFree quick user bases for your projectsTuser allows you to create databases for users of your project.FeaturesQuick start. You don't need to design a database for a long time - just one command will save you from torment.Safety. The data is completely secured by an encryption system and access level differentiation.Comfortable. All in one package without unnecessary things.Completely free of charge. Although I will not refuse donations :0SetupInstall via pipEnter the following line in the terminal$ pip install tuser     // in case pip using
    $ pip3 install tuser    // in case pip3 usingCreate base for projectNow you need to create a database and attach it to your project. To do this, enter the following command:$ tuser quickThen choose a name for your database:Base name: testbaseAfter that Tuser will create config file in 'site-packages' folder. Do not change it and keep it safe.Terminal commandsSee structure of your baseTo see the structure of you base type in the terminal following line:$ tuser structAdd field to your baseTo add field to your base type following line:$ tuser add-field [field-name] [int/varchar]At the moment Tuser can add 2 types of fields to your base:Integer (int)Varchar (varchar)Max length of varchar is 255 chars.Recreate or clear baseFor create new base or complete clear existing user 'quick' command:$ tuser quickUsing in projectConcierge checkpointCreate a Concierge object. Concierge is a checkpoint for all users and connections with Tuser.fromTuser.ConciergeimportConciergecheckpoint=Concierge()# in case your project has no foldercheckpoint=Concierge(username="some_username",password="some_password",table="some_table")# in case of usage not from root directory (RECOMENDED)Concierge structureConcierge is an object that store all your Tuser base data from name to pass data. Also contains user object.Concierge fields:
        - User  (public)
        - Login (private)
        - Pass  (private)
        - Base  (private)
      
    Concierge methods: 
        - Register      (username: str, password: str)              -> OperationStatus 
        - Login         (username: str, password: str)              -> OperationStatus 
        - SetUserField  (fieldName: str, fieldValue, userId = None) -> OperationStatus 
        - GetUserField  (fieldName: str, userId = None)             -> OperationStatus
        
    Concierge response template: OperationStatus objectUser registrationUseRegistermethod of Concierge object to add a new user. If there is no configuration file, Tuser will throw an exception.
Takes 2 arguments username and password. Returns the operation status object.fromTuser.ConciergeimportConciergecheckpoint=Concierge()checkpoint.Register("some_username","some_password")User loginUseLoginmethod of Concierge object to log in user. If there is no configuration file, Tuser will throw an exception. Takes 2
arguments: username and password. Returns the operation status object. In case of successful authorization,
the Concierge object will contain the user object in the 'user' field.fromTuser.ConciergeimportConciergecheckpoint=Concierge()checkpoint.Login("some_username","some_password")Set user fieldUseSetUserFieldmethod to set a value to user field. If there is no configuration file,
Tuser will throw an exception. Takes 2 required arguments: field name and value. Takes 1 optional
argument - User ID. If the user ID is not set, the current authorized user from the Concierge object is taken
as the ID. Returns the operation status object.Make sure you are setting an existing field. To create user field useTuser terminal command.fromTuser.ConciergeimportConciergecheckpoint=Concierge()checkpoint.SetUserField("user_score",500)# without pointing user id. Will set a field for current authorized user from Concierge objectcheckpoint.SetUserField("user_score",500,4)# with pointing user Idstatus=checkpoint.SetUserField(fieldName="user_score",fieldValue=500,userId=5)# recommended form for calling methodGet user fieldUseGetUserFieldmethod to get value of user field. If there is no configuration file, Tuser will
throw an exception. Takes 1 required argument - the name of the field. Takes 1 optional argument - User
ID. If the user ID is not set, the current authorized user from the Concierge object is taken as the ID.
Returns the operation status object.Value of the field will be stored indatafield of operation status object.Make sure you are setting an existing field. To create user field useTuser terminal command.fromTuser.ConciergeimportConciergecheckpoint=Concierge()status=checkpoint.GetUserField("some_field")value=status.dataOperation status objectIt is an object that contains data of sent request to the Tuser API. Here is a structure of OperationStatus and its possible fields.NameTypeDescriptionokrequired boolResult of the requestsystemVerboseoptional strMessage if the 'ok' field is FalseerrorCodeoptional intCode of error if the 'ok' field is Falsedataoptional AnyField that may contain some data from requests