Skip to content

Add FORCE_SQLITE Toggle to Avoid Database Conflicts #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jimboswankster
Copy link

Description:
This pull request introduces a FORCE_SQLITE toggle to address database conflicts when using PraisonAI in environments where Supabase or PostgreSQL databases are active. Additionally, it includes a README update and an optional patch system for ease of use in similar situations.

Here’s a well-formatted description for your pull request:


Title:

Add FORCE_SQLITE Toggle to Avoid Database Conflicts


Description:

This pull request introduces a FORCE_SQLITE toggle to address database conflicts when using PraisonAI in environments where Supabase or PostgreSQL databases are active. Additionally, it includes a README update and an optional patch system for ease of use in similar situations.


Changes:

  1. FORCE_SQLITE Toggle in db.py

    • A new toggle variable (FORCE_SQLITE) has been added to the praisonai/ui/db.py file.
    • When set to True, PraisonAI will bypass the detection of Supabase/Postgres and exclusively use SQLite as the database backend.
    • This resolves schema conflicts caused by incompatible users table definitions between PraisonAI and production applications.
    • This is a necessary feature for data security and safety during production.
    • Separation of concerns: keep the real db safe, while working with the praisonAi [code] tool.
  2. Enhanced Logging

    • Added informative logging to indicate whether the SQLite mode is being forced or a database URL is being detected.
  3. Patch System Directory

    • Created a codePatches directory with a copy of the patched db.py for users who might need to apply similar fixes without editing the source directly.
    • Added a README file to explain the purpose and usage of these patches.
  4. Updated .gitignore

    • Ensured virtual environments and unnecessary files are ignored in the repository.
  5. Documentation

    • Updated the praisonai/ui/README.md file to include an explanation of the FORCE_SQLITE feature and how to enable it.

Why This Change Is Necessary:

  • Problem: In environments where both PraisonAI and a production application share the same .env file, PraisonAI prioritizes Supabase/Postgres connections over SQLite. This leads to schema conflicts, particularly with the users table.
  • Solution: By adding the FORCE_SQLITE toggle, users can explicitly direct PraisonAI to use a local SQLite database, ensuring separation between production databases and the tool's data needs.

How to Use:

  1. Set FORCE_SQLITE = True in praisonai/ui/db.py.
  2. Ensure the .env file does not interfere with this behavior.
  3. Run PraisonAI as usual; it will now use SQLite exclusively.

Notes for Maintainers:

  • If centralizing configuration (e.g., toggles like FORCE_SQLITE) is desirable, I am happy to contribute a separate PR to introduce a centralized config system.
  • If this patch is accepted, consider documenting the FORCE_SQLITE toggle in the primary documentation for broader user awareness.

Testing:

  • Tested in an environment with conflicting database schemas (Supabase + PraisonAI) and confirmed that enabling the FORCE_SQLITE toggle successfully isolated PraisonAI to SQLite.

Let me know if there are any additional adjustments you'd like me to make! It is my opinion that this would be well suited for a centralized config file where the user can select whichever database they want used instead of having auto-detect, or in addition to having autodetect.


I love you 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.

1 participant