Skip to main content

orm peewee integrating plugin for bottle

Project description

init database and make hook before/after for disable fucking error --> 2006, 'MySQL server has gone away
database access in context application in app.db
struct application for avoid mutual imports, example:
# ---------------------------------------------------------------------------
# MYSQL config
# ---------------------------------------------------------------------------
MYSQL_HOST = 'localhost'
MYSQL_NAME = 'bottle'
MYSQL_USER = 'anonym'
MYSQL_PASSWD = 'anonympassword'
MYSQL_ENGINE = 'playhouse.pool.PooledMySQLDatabase'

'name': MYSQL_NAME,
'engine': MYSQL_ENGINE,
'user': MYSQL_USER,
'passwd': MYSQL_PASSWD,
'port': MYSQL_PORT,
'max_connections': MYSQL_DB_MAX_CONNECTION,
'stale_timeout': MYSQL_STALE_TIMEOUT
} - create database class, define models database use in project
from peewee import *
import config
from spouk_bottle_peewee import Database

db = Database(database_config=config.DATABASE_MYSQL)

class Sucker(db.Model):
id = PrimaryKeyField()
username = TextField(default=None)
password = TextField(default=None)
status = BooleanField(default=False) - create app = Bottle(), import from db=Database(...), app.install(db)
from model import db
from bottle import Bottle, template

app = Bottle()
from app import app
from model import Sucker

@app.get('/listsuckers, name='listsuckers')
def suck():
return jinja2_template('users.html', users=lsuck)

{% if users %}
{% for user in users %}
{{ }} {{user.username}} {{ user.password }} {{ user.status }} <br/>
{% endfor %}
{% endif %}

a brief example of the use, enjoy
in fact, variations in the use and application within the bottle is large enough to
describe this here, practice and experiments to achieve the desired goals you
Copyleft [x] 2015, Spouk

Project details

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page