1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 ==========
19 DB stuff
20 ==========
21
22 DB stuff.
23 """
24 __author__ = u"Andr\xe9 Malo"
25 __docformat__ = "restructuredtext en"
26
27
28 from wtf.ext.db import _config
29 from wtf.ext.db import _connection
30 from wtf.ext.db import _tagged as tagged
31 from wtf.ext.db._decorators import connection, transaction
32 from wtf.ext.db._exceptions import __all__
33 from wtf.ext.db._exceptions import *
34 from wtf.ext.db._service import DBService
35 __all__ = __all__ + [
36 'driver', 'connect', 'configure', 'connection', 'transaction', 'tagged',
37 'DBService',
38 ]
39
40
42 """
43 Determine driver module
44
45 :Parameters:
46 `dbname` : ``str``
47 DB name (section token in db.conf)
48
49 :Return: Driver module
50 :Rtype: ``module``
51
52 :Exceptions:
53 - `DBConfigurationError` : DB not configured
54 - `KeyError` : DB name not found
55 - `ImportError` : Driver not found
56 """
57 return _connection.driver(dbname)
58
59
61 """
62 Connect to database
63
64 :Parameters:
65 `dbname` : ``str``
66 DB name (section token in db.conf)
67
68 `kwargs` : ``dict``
69 Additional parameters for adapter connect() call
70
71 :Return: new connection
72 :Rtype: connection object (DBAPI 2)
73
74 :Exceptions:
75 - `DBConfigurationError` : DB not configured
76 - `KeyError` : DB name not found
77 - `ImportError` : Driver not found
78 """
79 return _connection.connect(dbname, **kwargs)
80
81
101 if configure.__doc__:
102
103 configure.__doc__ = configure.__doc__ % (_config.DEFAULT_CONF,)
104
105
106 try:
107 configure()
108 except DBConfigurationError:
109 pass
110