forked from coderbuzz/bottle-peewee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKG-INFO
66 lines (52 loc) · 1.94 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Metadata-Version: 1.0
Name: bottle-peewee
Version: 0.1
Summary: Peewee integration for Bottle.
Home-page: http://www.coderbuzz.com
Author: Indra Gunawan
Author-email: indra.sync@gmail.com
License: MIT
Description:
Bottle-Peewee is a plugin that integrates Peewee with your Bottle
application. It automatically connects to a database at the beginning of a
request, passes the database handle to the route callback and closes the
connection afterwards.
To automatically detect routes that need a database connection, the plugin
searches for route callbacks that require a `db` keyword argument
(configurable) and skips routes that do not. This removes any overhead for
routes that don't need a database connection.
Usage Example::
import bottle
import peewee
from peewee import *
from bottle_peewee import Database, Plugin
app = bottle.Bottle()
db = Database('db/sample.db', 'peewee.SqliteDatabase', autocommit=False)
class BaseModel(Model):
class Meta:
database = db.database
class User(BaseModel):
name = CharField()
User.create_table(fail_silently=True)
User.create(name='A')
User.create(name='B')
User.create(name='C')
plugin = Plugin(db)
app.install(plugin)
@app.route('/')
def index(db):
users = User.select()
result = "".join(["<li>%s</li>" % user.name for user in users])
return "Here is:<br><ul>%s</ul>" % result
if __name__ == '__main__':
bottle.debug(True)
bottle.run(app, reloader=True)
Platform: any
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires: bottle (>=0.9)