Skip to content

Feature/multi database support#44

Open
guptam38-roche wants to merge 9 commits intomainfrom
feature/multi-database-support
Open

Feature/multi database support#44
guptam38-roche wants to merge 9 commits intomainfrom
feature/multi-database-support

Conversation

@guptam38-roche
Copy link
Copy Markdown
Collaborator

Feat: Add cross-database support for SQLite and PostgreSQL

This PR implements database-agnostic functionality allowing the application
to work seamlessly with both SQLite and PostgreSQL backends. Users can now
switch between database engines by simply changing an environment variable.

Key changes:

  • Created database-agnostic field implementations for JSON and UUID fields
  • Fixed datetime serialization for consistent API responses
  • Added proper UUID handling across database engines
  • Implemented defensive error handling for cross-database compatibility
  • Added SQLite-specific database configuration options

The application now detects the database type at runtime and adapts field
storage/retrieval accordingly, ensuring consistent behavior regardless of
the underlying database engine.

Testing:

  • Ensured API responses match between both database engines

…h both

PostgreSQL and SQLite backends. The changes detect the database type at runtime
and use appropriate strategies for each:

- PostgreSQL: Continue using the RETURNING clause to get inserted IDs
- SQLite: Track IDs before insertion and verify with a follow-up query

This fixes the "not iterable" error that occurred when trying to process
SQLite's integer return value from insert_many().execute().
@dhars9-roche dhars9-roche requested review from huany172-roche and removed request for dhars9-roche April 28, 2025 21:10
Copy link
Copy Markdown
Contributor

@huany172-roche huany172-roche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have another two test databases and run the unit tests, see if they pass after the changes. i.e., models/test/*.py. Thanks!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants