Skip to content
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

Create database connection #586

Open
12 tasks
monikkaelyse opened this issue Feb 8, 2025 · 1 comment
Open
12 tasks

Create database connection #586

monikkaelyse opened this issue Feb 8, 2025 · 1 comment

Comments

@monikkaelyse
Copy link
Collaborator

monikkaelyse commented Feb 8, 2025

Problem

We need a persistent storage solution and the ability to perform basic data operations.

Description

Now that we have databases, we need to connect to them in the code. This should be in its own file so any other python files can import it.

Expected Behavior

A new database connection file is created and is able to connect to the database.

Suggestion (actual implementation may vary)

  1. Add sqlalchemy and mysqlclient to requirements.in (note: sqlalchemy will be our ORM, it can also be used to create a db connection engine)
  2. Generate the requirements.txt based on the pip-compile instructions in the readme
  3. Install the new requirements
  4. Create a new python file to connect to the database using the credentials from .env. Example:
# db_connection.py
def get_db_connection():
    mydb = 'insert code here'
    return mydb
  1. Test importing this new function into main_site.py. Verify that the connection works.

Acceptance Criteria

  • Database is properly set up and accessible from the application
    • New DB connection file is created that connects to the database
    • File is able to be imported into main_site.py
    • DB file pulls from .env variables to connect
  • Ensure that if the .env variables aren’t accessible, the website still works even without db connection
  • Connection to db is validated and working
    • Error handling provides meaningful feedback for database operations
    • Data validation prevents invalid data from being stored
  • New libraries are in requirements
  • Document (in your code) any models for applicants, admins, and applications
  • Document (in your code) any CRUD operations related to applicants, admins, and applications, for example:
    • Create: Insert new records
    • Read: Retrieve records
    • Update: Modify existing records
    • Delete: Remove records
  • Identify and create any sub-issues required for updating existing model / files (i.e. updating the application form to connect to the database)

Technical Concepts

  • SQL database management
  • ORM (Object-Relational Mapping) concepts
  • Database design and normalization
  • CRUD operations
  • Data validation and sanitization

Additional Context

You will need to have the credentials in a .env -- please get that from @monikkaelyse .

@monikkaelyse
Copy link
Collaborator Author

Note - please add me as a reviewer on this PR, thank you!

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

No branches or pull requests

2 participants