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()

    db.session.add(User(username="example"))
    db.session.commit()

    users = db.session.execute(db.select(User)).scalars()

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.4.tar.gz (78.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_sqlalchemy-3.0.4-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file flask_sqlalchemy-3.0.4.tar.gz.

File metadata

  • Download URL: flask_sqlalchemy-3.0.4.tar.gz
  • Upload date:
  • Size: 78.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for flask_sqlalchemy-3.0.4.tar.gz
Algorithm Hash digest
SHA256 b812bc7f1bbf5ff3041cbfa0428bb191bed2c342b7bed88c15d7ce01890bfd5d
MD5 96eb4fe119815037f8b9cd16712014e2
BLAKE2b-256 d6206a2c0b739ca89907bd30fa91395da76a3ff3756230c590c46a7119ea7bb0

See more details on using hashes here.

File details

Details for the file flask_sqlalchemy-3.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_sqlalchemy-3.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 23d44ca566b02b0b5ee5b29d81b435079402ad73c116bf9918dbda5b03aa30ba
MD5 3396c73668bf351356835d4ba8566c15
BLAKE2b-256 2a478f9010cd80553e26c7d4533f1972d04648f49edde2aa2895636792364aad

See more details on using hashes here.

Supported by

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