All Projects → iurisilvio → Bottle Sqlalchemy

iurisilvio / Bottle Sqlalchemy

Licence: mit
Bottle SQLAlchemy plugin

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Bottle Sqlalchemy

Sqlalchemy Media
Another attachment extension for SqlAlchemy to manage assets which are associated with database models but you don't want to store them into the database
Stars: ✭ 69 (-44.8%)
Mutual labels:  sqlalchemy
Flask movie site
用Flask构建一个微电影视频网站
Stars: ✭ 97 (-22.4%)
Mutual labels:  sqlalchemy
Flask Graphene Sqlalchemy
⚗️Project template to build a GraphQL API in Python
Stars: ✭ 109 (-12.8%)
Mutual labels:  sqlalchemy
Sqlalchemy Hana
SQLAlchemy Dialect for SAP HANA
Stars: ✭ 75 (-40%)
Mutual labels:  sqlalchemy
Flask Tutorial
这个项目已经很久很久了, 不推荐看, 不过倒是可以进群叨逼叨一下. 🚗 交流群:630398887
Stars: ✭ 91 (-27.2%)
Mutual labels:  sqlalchemy
Booklibrary
📚Simple Book library application written on flask with SQLite database.
Stars: ✭ 98 (-21.6%)
Mutual labels:  sqlalchemy
Wtforms Sqlalchemy
WTForms integration for SQLAlchemy
Stars: ✭ 68 (-45.6%)
Mutual labels:  sqlalchemy
Tornado Sqlalchemy
SQLAlchemy support for Tornado
Stars: ✭ 112 (-10.4%)
Mutual labels:  sqlalchemy
Markbj
一个开放的知识社区
Stars: ✭ 94 (-24.8%)
Mutual labels:  sqlalchemy
Sqlalchemy Imageattach
SQLAlchemy extension for attaching images to entities.
Stars: ✭ 107 (-14.4%)
Mutual labels:  sqlalchemy
Data Driven Web Apps With Pyramid And Sqlalchemy
Demos and handouts for Talk Python's Data-Driven Web Apps with Pyramid and SQLAlchemy course
Stars: ✭ 79 (-36.8%)
Mutual labels:  sqlalchemy
Pyathenajdbc
PyAthenaJDBC is a Python DB API 2.0 (PEP 249) compliant wrapper for Amazon Athena JDBC driver.
Stars: ✭ 90 (-28%)
Mutual labels:  sqlalchemy
Pyhive
Python interface to Hive and Presto. 🐝
Stars: ✭ 1,378 (+1002.4%)
Mutual labels:  sqlalchemy
Sql to sqlalchemy
本教程是为了展现 sql 原始语句转换为 sqlalchemy 语句的各个实例。
Stars: ✭ 75 (-40%)
Mutual labels:  sqlalchemy
Pymapd
Python client for OmniSci GPU-accelerated SQL engine and analytics platform
Stars: ✭ 109 (-12.8%)
Mutual labels:  sqlalchemy
Indico
Indico - A feature-rich event management system, made @ CERN, the place where the Web was born.
Stars: ✭ 1,160 (+828%)
Mutual labels:  sqlalchemy
Oreilly reactive python for data
Resources for the O'Reilly online video "Reactive Python for Data"
Stars: ✭ 98 (-21.6%)
Mutual labels:  sqlalchemy
Flask Graphene Sqlalchemy
A demo project for Flask + GraphQL (With Graphene & SQLAlchemy)
Stars: ✭ 117 (-6.4%)
Mutual labels:  sqlalchemy
Sqla Wrapper
A friendly wrapper for SQLAlchemy
Stars: ✭ 111 (-11.2%)
Mutual labels:  sqlalchemy
Weeklyreport
基于Flask的开源周报系统,快速docker部署
Stars: ✭ 102 (-18.4%)
Mutual labels:  sqlalchemy

This bottle-sqlalchemy plugin integrates SQLAlchemy with your Bottle application. It injects a SQLAlchemy session in your route and handle the session cycle.

Usage Example:

import bottle
from bottle import HTTPError
from bottle.ext import sqlalchemy
from sqlalchemy import create_engine, Column, Integer, Sequence, String
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
engine = create_engine('sqlite:///:memory:', echo=True)

app = bottle.Bottle()
plugin = sqlalchemy.Plugin(
    engine, # SQLAlchemy engine created with create_engine function.
    Base.metadata, # SQLAlchemy metadata, required only if create=True.
    keyword='db', # Keyword used to inject session database in a route (default 'db').
    create=True, # If it is true, execute `metadata.create_all(engine)` when plugin is applied (default False).
    commit=True, # If it is true, plugin commit changes after route is executed (default True).
    use_kwargs=False # If it is true and keyword is not defined, plugin uses **kwargs argument to inject session database (default False).
)

app.install(plugin)

class Entity(Base):
    __tablename__ = 'entity'
    id = Column(Integer, Sequence('id_seq'), primary_key=True)
    name = Column(String(50))

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return "<Entity('%d', '%s')>" % (self.id, self.name)


@app.get('/:name')
def show(name, db):
    entity = db.query(Entity).filter_by(name=name).first()
    if entity:
        return {'id': entity.id, 'name': entity.name}
    return HTTPError(404, 'Entity not found.')

@app.put('/:name')
def put_name(name, db):
    entity = Entity(name)
    db.add(entity)

@app.get('/spam/:eggs', sqlalchemy=dict(use_kwargs=True))
@bottle.view('some_view')
def route_with_view(eggs, db):
    # do something useful here

It is up to you create engine and metadata, because SQLAlchemy has a lot of options to do it. The plugin just handle the SQLAlchemy session.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].