Skip to content

Conversation

@Yusufibin
Copy link

  1. Enhanced search functionality: Added support for substring and case-insensitive searches in the search_data method.
  2. Configurable logging system: Replaced all print statements with a proper logging system using Python's logging module, allowing users to control log levels and output.

Changes Made

Search Improvements (modules/search.py and LiteJsonDb.py)

  • Added optional parameters substring (default: False) and case_sensitive (default: True) to search_data.
  • Updated search logic to support partial matches and case-insensitive comparisons while maintaining backward compatibility.
  • Improved docstrings to document the new parameters.

Logging System (LiteJsonDb.py and all handler/modules files)

  • Introduced a LiteJsonDb logger with console output for user messages.
  • Replaced all print statements in handler/db_operations.py, handler/encrypt.py, handler/method.py, modules/search.py, modules/csv.py, and LiteJsonDb.py with appropriate logger calls (logger.error, logger.info).
  • Preserved ANSI color codes in log messages for better readability.
  • Logging is enabled by default when enable_log=True in JsonDB initialization.

Backward Compatibility

  • All existing APIs remain unchanged; new parameters are optional.
  • Default behavior matches the previous version (exact, case-sensitive search; console output for messages).

Testing

To test the changes:

  1. Import the library: import LiteJsonDb
  2. Create a database: db = LiteJsonDb.JsonDB(enable_log=True)
  3. Add data: db.set_data('users/1', {'name': 'Alice', 'age': 30})
  4. Test search:
    • Exact: db.search_data('Alice')
    • Substring: db.search_data('Ali', substring=True)
    • Case-insensitive: db.search_data('ALICE', case_sensitive=False)
  5. Check console logs for messages (e.g., errors on invalid operations).

@codingtuto
Copy link
Owner

@Yusufibin Wow 🔥 what a contribution! We’ll all check this out 👀
Thanks @Yusufibin for these awesome improvements — enhanced search and clean logging system, that’s top-notch work 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants