Git Product home page Git Product logo

flask-db-connection's Introduction

Flask Project with Different Database Connections

This repository contains a Flask project that demonstrates how to connect to different types of databases. It includes examples for MySQL, PostgreSQL, and MongoDB.

Installation

To run this project locally, follow these steps:

  1. Clone the repository to your local machine using the following command:

    git clone https://github.com/your-username/flask-database-connections.git
    
  2. Navigate to the project directory:

    cd flask-database-connections
    
  3. Create a virtual environment to isolate the project's dependencies:

    python -m venv env
    
  4. Activate the virtual environment:

    • On macOS and Linux:

      source env/bin/activate
      
    • On Windows:

      .\env\Scripts\activate
      
  5. Install the project dependencies:

    pip install -r requirements.txt
    
  6. Create a .env file in the project directory with the following contents:

    FLASK_APP=app
    FLASK_ENV=development
    DATABASE_URL=mysql+pymysql://username:password@localhost/database_name
    MONGO_URI=mongodb://localhost:27017/database_name
    

    Replace username, password, and database_name with your own values.

  7. Run the Flask development server:

    flask run
    
  8. Open your web browser and visit http://localhost:5000 to access the application.

Usage

This Flask application demonstrates how to connect to different types of databases using SQLAlchemy. Here are the available routes:

  • /mysql: Displays data from a MySQL database.
  • /mongo: Displays data from a MongoDB database.

Each route connects to a different type of database and displays data from it.

Feel free to explore the project's code and modify it according to your needs.

License

This project is licensed under the MIT License.

Contact

If you have any questions or suggestions, feel free to contact us at [email protected].

flask-db-connection's People

Contributors

partner0307 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.