feat: Add MultiDBStore: Multi-Database Token Persistence via SQLAlchemy#5
Open
harshdadiya-wappnet wants to merge 1 commit intozoho:mainfrom
Open
Conversation
- Adds MultiDBStore class supporting PostgreSQL, MySQL, SQLite, Oracle, SQL Server - Maintains 100% API compatibility with official MySQL DBStore - Fixes SQL injection vulnerability via parameterized queries - Improves thread-safety with UUID generation - Adds connection pooling and resource management - Includes comprehensive logging and error handling - Adds unit tests for all operations Benefits: - Users no longer limited to MySQL - Better security (no SQL injection) - Better performance (connection pooling) - Better reliability (proper resource management) Tested on: - PostgreSQL 12+ - MySQL 5.7+ - SQLite 3.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces
MultiDBStore, a modern token persistence implementation that extends database support beyond MySQL to any SQL database supported by SQLAlchemy, while maintaining full API compatibility with the existingDBStore.✨ Key Improvements
🌐 Multi-Database Support
DBStore→ seamless migration🔒 Enhanced Security
DBStore📈 Better Scalability
UUID-based token IDs
Built-in connection pooling
Automatic reconnection handling
Production-grade error handling
🛠️ Developer-Friendly
TokenStore🗂️ Changes Made
➕ New File
TokenStoreabstract class✏️ Modified Files
Added MultiDBStore documentation
Usage examples:
Installation instructions
Comparison table:
DBStorevsMultiDBStore🔄 API Compatibility
✅ Fully implements all
TokenStoremethods:find_token(token)find_token_by_id(id)save_token(token)delete_token(id)get_tokens()delete_tokens()generate_id()(new)🔁 Migration from
DBStoreBefore
After
➡️ Same schema. No data migration required.
📦 Dependencies
Required
Optional Database Drivers
psycopg2-binary– PostgreSQLpymysql– MySQL / MariaDBcx_Oracle– Oraclepyodbc– SQL Server🧪 Testing
📚 Documentation
✅ README updated with:
✅ Inline documentation:
🔐 Security Note (Important)
This implementation eliminates SQL injection risks present in the official
DBStoreby replacing raw SQL string concatenation with SQLAlchemy’s parameterized queries.✅ Checklist
TokenStoremethods implemented🔮 Future Enhancements (Not in This PR)
asyncio)📁 Files Changed
📊 Lines Changed
📝 Reviewer Notes
@raja-k-7453 , @tharun-pargi-15510 Please review the updates