Package: htconnector
htconnector Framework:htconnector is a python framework for creating desktop and mobile applications. It enables you to link your application to a database. This framework usesPostgreSQL.NB: If you use it without database, sorry the framework is unusableAbout us:Created by Hizart.Soft H._T coorp@2022 _ based harsdevhtconnector version 1.0Why use htconnector?Facilitates the connection between your application and the databaseReduces the number of written codesFast and secureHelp for keyword:KeywordDescriptionConnectBaseStorages()Connect to database by fill your key paramsHTBASE : db_nameHTUSER : userHTPASS : passwordHTHOST : hostHTPORT : portDisconnectBaseStorages()Disconnect to databaseFetchDataFrom()Get all data from database, this fetch all data existon database without filter.This is recommanded for free dataUseDefaultUserModel()Use default user modelThis is default table by thconnector. relational dbUseMd5()Encrypt password security with md5CreateUser()Create user by default modelAuthForUser()Authantification after registerUpdateUserValue()Update user value, useruser_idDeleteUserValue()Delete user value, don't forgetuser_idLogoutUser()Logout user connectedInstallation:Install postgresqlhttps://www.postgresql.org/download/if you using linux , ubuntu, follow the scriptsudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresqllnstallation requirespip install psycopg2
or
pip install psycopg2-binaryInstall framework for window/mac/linuxpip install htconnector
pip3 install htconnector (for the version of python3)Usage of htconnector (The documentation):Compement:Connect databaseInsert dataFetch dataDefault model for registration an loginThe base of connection.from htconnector.connector import (
         ConnectBaseStorages,  
	 DisconnectBaseStorages,  
	 ExecuteBaseData,  
	 FetchDataFrom 
	)Replace 'your_dbname', 'your_user', and 'your_password' with your actual database credentials.To connect your application to server you must define use the functionConnectBaseStorages()db_connection, db_cursor = ConnectBaseStorages(
           htbase = 'your_dbname',  
           htuser = 'your_user',
           htpass = 'your_password',  
           hthost = 'your_host',   
           htport = 'your_port'  
       )If you create custom parameters using input , you can try this example:dbname = input('Enter your db_name: ')
username = input('Enter your username: ')
password = input('Enter your password: ')
host = input('Enter your host: ')
port = input('Enter your port: ')

connect_to, db_cursor = ConnectBaseStorages(
    htbase = dbname,
    htuser = username,
    htpass = password,
    hthost = host,
    htport = port
)Example query execution.create_table_query = """ 
        CREATE TABLE IF NOT EXISTS example_table (
		id SERIAL PRIMARY KEY,  
 		name VARCHAR(100),   
		age INTEGER   
	);     """  
  execute_query(db_cursor, create_table_query)Example data insertion.insert_data_query = "INSERT INTO example_table (
	name,age) VALUES (%s, %s);"   
 data = ('John Doe', 30)   
 execute_query(db_cursor, insert_data_query, data)Example data retrieval.select_data_query = "SELECT * FROM example_table;"   
result = FetchDataForm(db_cursor, select_data_query)   
print(result)Disconnect from the database when doneDisconnectBaseStorages(db_connection, db_cursor)Use htmodel user.from htconnector.connector import (
         ConnectBaseStorages,  
	 DisconnectBaseStorages,  
	 ExecuteBaseData,  
	 FetchDataFrom,
	 UseDefaultUserModel #import if you need to use htcase_user
	)

#compulsory packages: UseDefaultUserModelThe htmodel contain.It's a bit like the Django model, but here you don't have to use the functionUseDefaultUserModel.username
password
email
firstname
lastname
is_activegenderTo use the default user table , follow this code:#Create default user::
UseDefaultUserModel(db_cursor)Insert with security MD5pass_data = UseMd5("You_password")

#Insert data to the htcase_user table::
insert_user = """
    INSERT INTO user_table (username, password, email, lastname, firstname, is_active, gender)
    VALUES (%s, %s, %s, %s, %s, %s, %s);
"""
user_data = ('hizart', pass_data, 'hizart@example.com', 'Harry', 'Tahiana', True, 'Male')
execute_query(db_cursor, insert_user, user_data)Create User by default table:If you useUseDefaultUserModel, you can create Registration and Login by default models. To make it , you need to import moduleCreateUserandAuthForUser.CreateUser: Use for creating user (admin or simple user)AuthForUser: For login accessfrom htconnector.connector import (
	#Your exist module here:
	CreateUser,
	AuthForUser
)don't forget to make it. (call back function).CreateUser(db_cursor=db_cursor)
AuthForUser(db_cursor=db_cursor)When you Login , you can logged, no paramsLogoutUser().LogoutUser()After creating user , you can update and delete value from database by using this function.UpdateUserValue(db_cursor=db_cursor, user_id)

#You can use to:
DeleteUser(db_cursor, user_id)