Skip to main content

Adds SQLAlchemy support to your Flask application.

Project description

SQLAlchemy-Handler is an extension that still like Flask-SQLAlchemy adds more support for SQLAlchemy to your application. It helps to handle models with humanized ids once it is jsonified, throws api errors for some casting of value during the save time.

[![CircleCI](https://circleci.com/gh/betagouv/sqlalchemy-handler/tree/master.svg?style=svg)](https://circleci.com/gh/betagouv/sqlalchemy-handler/tree/master) [![Coverage Status](https://coveralls.io/repos/github/betagouv/sqlalchemy-handler/badge.svg)](https://coveralls.io/github/betagouv/sqlalchemy-handler)

Installing

Install and update using pip:

$ pip install -U SQLAlchemy-Handler

A Simple Example

from flask import Flask
from sqlalchemy_handler import Handler

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

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

user = User(username="Flask", email="example@example.com")
Handler.save(user)

Deploy

First, make sure that the deploy environment is started:

./sqlah start

In a second tab, then:

  1. Change the __version__ into sqlalchemy_handler/__init__.py

  2. Pre publish:

./sqlah prepublish
  1. Publish:

./sqlah publish

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

SQLAlchemy-Handler-0.0.3.tar.gz (14.7 kB view hashes)

Uploaded Source

Built Distribution

SQLAlchemy_Handler-0.0.3-py2.py3-none-any.whl (16.6 kB view hashes)

Uploaded Python 2 Python 3

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