Skip to content

Database Library (MySQL)

Trevor Geene edited this page Jan 4, 2021 · 5 revisions

THIS PAGE IS CURRENTLY OUT OF DATE

Using MySQL

Install Nessicary Requirements:

pip install pymysql
pip install cryptography

Example Config:

db_config = {
	'driver': 'mysql',
	'host': '127.0.0.1',
	'port': 3306,
	'database': 'flask_mvc_framework',
	'authorize': True,  # ignore for mysql
	'username': 'tester',
	'password': 'password'
}

Example Usage

insert = {
	'example_field_1': "test string",
	'example_field_2': 3,
	'example_field_3: False
}
insert = database_helper.clean_dict(insert)
insert_id = db.insert_one('example_db_table', insert)

Function List

Function Example
Get One Record db.get_one(table_name='', where_obj={}, col_select='*')
Get Multiple Records db.get(table_name='', where_obj={}, col_select='*')
Get Record Count db.get_count(table_name='', where_obj={})
Insert One Record db.insert_one(table_name='', data_obj={})
Insert Multiple Records insert_many(table_name='', data_obj=[])
Update Record(s) db.update(table_name='', where_obj={}, data_obj={})
Delete Record(s) db.delete(table_name='', where_obj={})