Package: pygravit
PyGravitModule for managing accounts in GravitLauncher DatabaseAboutThe library is designed to manage the database of GravitLauncher players. This library is not considered official. It has four methods for managing players, which are provided below, as well as in the examples. There are also error handlers, which can also be found in the documentation below.InstallationUpdate your pipInstall the pygravit package either via pip or from the pypi websiteInstallation commandpython-mpipinstallpygravitImport it into your projectImportsfrompygravitimportPyGravitfrompygravitimport(DatabaseConnectionError,NicknameInDatabaseError,NicknameNotInDatabaseError,AllowedCharactersNicknameError,ClassDatabaseNotConnectionError,NicknameLengthError,ParamNotFoundError,DataError)Check out the documentation for further work.Documentation1. Examplesapi_gravitpy_example.pyfrompygravitimportPyGravit# Connecting to a databaseGravitLauncher=PyGravit(db="dbname",host="ip/domainname",port=3306,user="username",passwd="password",table="tablename (default users)")# Creating a player in the databaseGravitLauncher.player_create("Nickname","Password")# Removing a player from the databaseGravitLauncher.player_delete("Nickname")# Changing the player (the parameters are in the GravitLauncher documentation as well as in the database itself)GravitLauncher.player_change("Nickname","Param","Value")# Getting the player parameter (the parameters are in the GravitLauncher documentation as well as in the database itself)GravitLauncher.player_get("Nickname","Param")custom_tablename.pyfrompygravitimportPyGravitGravitLauncher=PyGravit(db="dbname",host="ip/domainname",port=3306,user="username",passwd="password",table="server_users")#table default "users"# Creating two tables: server_users and server_users_hwids (default: users and users_hwids)except_processing.pyfrompygravitimportPyGravitfrompygravitimport(DatabaseConnectionError,NicknameInDatabaseError,NicknameNotInDatabaseError,AllowedCharactersNicknameError,ClassDatabaseNotConnectionError,NicknameLengthError,ParamNotFoundError,DataError)try:GravitLauncher=PyGravit(db="dbname",host="ip/domainname",port=3306,user="username",passwd="password",table="tablename (default users)")exceptDatabaseConnectionErrorase:print(e)try:GravitLauncher.player_create("Nickname","Password")except(NicknameInDatabaseErrororAllowedCharactersNicknameErrororNicknameLengthErrororDataErrororClassDatabaseNotConnectionError)ase:print(e)try:GravitLauncher.player_delete("Nickname")except(NicknameNotInDatabaseErrororDataErrororClassDatabaseNotConnectionError)ase:print(e)try:GravitLauncher.player_change("Nickname","Param","Value")GravitLauncher.player_get("Nickname","Param")except(NicknameNotInDatabaseErrororParamNotFoundErrororDataErrororClassDatabaseNotConnectionError)ase:print(e)2. ExceptionsDatabaseConnectionError - Failed to connect to database
NicknameInDatabaseError - Nickname already exists in the database
NicknameNotInDatabaseError - Nickname not found in database
AllowedCharactersNicknameError - Nickname has forbidden characters (forbidden in normal minecraft)
ClassDatabaseNotConnectionError - The database object is not a MySQLConnection
NicknameLengthError - Nickname does not meet standard length (either short or long)
ParamNotFoundError - The player parameter was not found in the database (used to get and change values in the database)
DataError - Failed to send data to database3. Classes and MethodsClassesPyGravit(db,user,passwd,host,port)-AnobjectclassforconnectingtoadatabaseMethodsplayer_create(nickname,password)-Creatingaplayerinthedatabaseplayer_delete(nickname)-Removingaplayerfromthedatabaseplayer_change(nickname,param,value)-Changingtheplayerplayer_get(nickname,param)-Gettingtheplayerparameter