A bundle of useful packages for managing login sessions and database
Project description
Session
Usage:
from burgos.session import Session
session = Session(database_auth, login_table)
database_auth: json/dict
{
"host": "host ip address or domain",
"database": "database name",
"user": "username",
"password": "user password"
}
login_table: string
"table_name_which_contains_login_data"
Built-in methods
database.reconnectDatabase()
- reconnects to the database
getConnection(ip)
- ip = string containing an ip address
- returns the connection matching the selected ip address
- if there is no connection with that ip, returns None
login(user, password, ip)
- user = string containing the username, email or cpf as login method
- password = string containg the password
- ip = string containing an ip address
- if "user" is number only, it will be checked as cpf
- if "user" has an "@", it will be checked as an email
- if "user" is neither, it will be checked as an username
- if there is a row in database.login_table that matches with this user and password, a Connection will be instanciated and the user id will be returned
Mysql
Usage:
from burgos.mysql_handler import Mysql
database = Mysql(login_table)
login_table: string
"table_name_which_contains_login_data"
Built-in methods
connect(auth:dict)
- auth = dictionary containing authentication data (same as session's database_auth)
- connects to the database and must be called before any other method (session already calls this in it's constructor)
disconnect()
- disconnects from the database
run(sql)
- sql = string containing SQL code
- sql code will be executed and commited into the database
- if sql first word, lowered, is equal to "select", this method will return a list containing the selected rows
fetchTable(table, rows = 0, where = [], reversed = None, ordered = None)
- table = string containing the table name which should be selected data from
- rows = int number that means the number of rows that should be selected. Optional (default: all rows)
- where = list containing strings which are the column and value. Ex.: where = ["username", "nandobfer"]. Optional.
- reversed = boolean indicating if the where query should be reversed or not. Optional.
- ordered = string containing the "ORDER BY" information. Ex. ordered = "id" / ordered = "datetime DESC"
- Returns a list containing another list for each row fetched. Returns an empty list if there was none.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
burgos-2.2.1.tar.gz
(29.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
burgos-2.2.1-py3-none-any.whl
(30.5 kB
view details)
File details
Details for the file burgos-2.2.1.tar.gz.
File metadata
- Download URL: burgos-2.2.1.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b38c95d48fb8b5573f0773bbc487963a8e464d613acc8655b3ca87da417c861
|
|
| MD5 |
062dc6d013a249ed23730fc2eef49e28
|
|
| BLAKE2b-256 |
ef5e166c7a906784c152cc14ccbbfaef07dff9b5ebc42bb1e5014c9cac075c5e
|
File details
Details for the file burgos-2.2.1-py3-none-any.whl.
File metadata
- Download URL: burgos-2.2.1-py3-none-any.whl
- Upload date:
- Size: 30.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d729d727146c2c2321c31f2884214f326243b04257e104c737d2c33044522e0
|
|
| MD5 |
c3adce3c83385210a897838de70ce152
|
|
| BLAKE2b-256 |
2acc3b1e2d4ad3f942cfab311e693224713f4acba604037e0f9904c7e4b2765a
|