Skip to main content

Add SQLAlchemy support to your Flask application.

Project description

Flask-SQLAlchemy is an extension for Flask that adds support for SQLAlchemy to your application. It aims to simplify using SQLAlchemy with Flask by providing useful defaults and extra helpers that make it easier to accomplish common tasks.

Installing

Install and update using pip:

$ pip install -U Flask-SQLAlchemy

A Simple Example

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///example.sqlite"
db = SQLAlchemy(app)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String, unique=True, nullable=False)

with app.app_context():
    db.create_all()

with app.app_context():
    db.session.add(User(username="example"))
    db.session.commit()

@app.route("/users")
def user_list():
    users = db.session.execute(db.select(User)).scalars()
    return render_template("user_list.html", users=users)

Contributing

For guidance on setting up a development environment and how to make a contribution to Flask-SQLAlchemy, see the contributing guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-SQLAlchemy-3.0.0a2.tar.gz (139.5 kB view details)

Uploaded Source

Built Distribution

Flask_SQLAlchemy-3.0.0a2-py2.py3-none-any.whl (24.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file Flask-SQLAlchemy-3.0.0a2.tar.gz.

File metadata

  • Download URL: Flask-SQLAlchemy-3.0.0a2.tar.gz
  • Upload date:
  • Size: 139.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for Flask-SQLAlchemy-3.0.0a2.tar.gz
Algorithm Hash digest
SHA256 5dc132381590d3a137ea794147b25af95999c4dd03af4cbe92eb2b935026a2b4
MD5 d8bc252aaf25fdd64f73c76e3215b9e1
BLAKE2b-256 12b5f6e02e6f16bb6bae9d5e084d1c9928e0e45882eadb1123e85c2254378cef

See more details on using hashes here.

File details

Details for the file Flask_SQLAlchemy-3.0.0a2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_SQLAlchemy-3.0.0a2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dca868f998d3790f2ea5d857af83da48f30d82842169fd7aa6292fbfb3fdbcc2
MD5 9630a2a75101cc1ec19fa5169d68b311
BLAKE2b-256 8edd97702b1341f5c4ff3223d4f34d2785c3083bc14783014bf1ffdb102d5417

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page