Files
CGW-Quote-Builder/app/data_access.py
T
2026-05-05 16:06:52 -05:00

92 lines
2.4 KiB
Python

"""
Data Access Layer
Automatically loads the correct data access module based on configuration
"""
import config
# Import the appropriate data access module based on config
if config.USE_DATABASE:
print("Using SQLite database for data storage")
from data_access_sqlite import (
# User operations
get_user_by_username,
get_user_by_id,
get_all_users,
create_user,
update_user,
delete_user,
toggle_user_active,
change_user_password,
# Product operations
get_all_products,
get_product_by_code,
create_product,
update_product,
delete_product,
# Location operations
get_all_locations,
get_location_by_code,
# Product attributes operations
get_product_attributes,
update_product_attributes,
# Utility functions
commit,
rollback
)
else:
print("Using JSON files for data storage")
from data_access_json import (
# User operations
get_user_by_username,
get_user_by_id,
get_all_users,
create_user,
update_user,
delete_user,
toggle_user_active,
change_user_password,
# Product operations
get_all_products,
get_product_by_code,
create_product,
update_product,
delete_product,
# Location operations
get_all_locations,
get_location_by_code,
# Product attributes operations
get_product_attributes,
update_product_attributes,
# Utility functions
commit,
rollback
)
# Re-export all functions so blueprints can do: from data_access import get_user_by_username
__all__ = [
# User operations
'get_user_by_username',
'get_user_by_id',
'get_all_users',
'create_user',
'update_user',
'delete_user',
'toggle_user_active',
'change_user_password',
# Product operations
'get_all_products',
'get_product_by_code',
'create_product',
'update_product',
'delete_product',
# Location operations
'get_all_locations',
'get_location_by_code',
# Product attributes operations
'get_product_attributes',
'update_product_attributes',
# Utility functions
'commit',
'rollback'
]