rabaDB2 2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rabadb2-2.0/CHANGELOG.rst +45 -0
- rabadb2-2.0/DESCRIPTION.rst +4 -0
- rabadb2-2.0/LICENCE +201 -0
- rabadb2-2.0/MANIFEST.in +2 -0
- rabadb2-2.0/PKG-INFO +35 -0
- rabadb2-2.0/README.rst +343 -0
- rabadb2-2.0/rabaDB/Raba.py +992 -0
- rabadb2-2.0/rabaDB/__init__.py +1 -0
- rabadb2-2.0/rabaDB/examples/BasicExample.py +33 -0
- rabadb2-2.0/rabaDB/examples/QueryExample.py +37 -0
- rabadb2-2.0/rabaDB/examples/__init__.py +1 -0
- rabadb2-2.0/rabaDB/fields.py +101 -0
- rabadb2-2.0/rabaDB/filters.py +306 -0
- rabadb2-2.0/rabaDB/rabaSetup.py +417 -0
- rabadb2-2.0/rabaDB2.egg-info/PKG-INFO +35 -0
- rabadb2-2.0/rabaDB2.egg-info/SOURCES.txt +19 -0
- rabadb2-2.0/rabaDB2.egg-info/dependency_links.txt +1 -0
- rabadb2-2.0/rabaDB2.egg-info/entry_points.txt +2 -0
- rabadb2-2.0/rabaDB2.egg-info/top_level.txt +1 -0
- rabadb2-2.0/setup.cfg +4 -0
- rabadb2-2.0/setup.py +79 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
2.1.0
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+
* Python 3 migration: fixed 25+ bugs blocking test coverage
|
|
5
|
+
* Fixed circular imports in fields.py
|
|
6
|
+
* Fixed recursion in Raba.__getattr__
|
|
7
|
+
* Fixed RabaList metaclass reference (RabaList_Metaclass -> _RabaListSingleton_Metaclass)
|
|
8
|
+
* Fixed RabaListPupa.insert signature (k,i,v -> i,v)
|
|
9
|
+
* Fixed RabaQuery.run() returning only first element (return inside for loop)
|
|
10
|
+
* Fixed RabaQuery._parseJoint() called with wrong number of args
|
|
11
|
+
* Fixed pickle.loads(str(...)) -> pickle.loads(bytes(...))
|
|
12
|
+
* Fixed hashlib.md5(str) -> hashlib.md5(str.encode('utf-8'))
|
|
13
|
+
* Fixed SQLite partial index parameter prohibition (inline values)
|
|
14
|
+
* Fixed dictionary changed size during iteration in metaclass __call__
|
|
15
|
+
* Fixed _mutateNotifyAnchor crash on free RabaList (anchorObj is None)
|
|
16
|
+
* Fixed RabaList.extend calling non-existent _checkRabaList
|
|
17
|
+
* Fixed RabaList.__setitem__/_checkElmt extra argument
|
|
18
|
+
* Fixed Raba.unreference referencing non-existent makeRabaObjectSingletonKey
|
|
19
|
+
* Added no-op unregisterRabalist and updateRabaListLength for backward compat
|
|
20
|
+
* Added test_rabadb_extended.py (184 new tests) -> 99% coverage
|
|
21
|
+
|
|
22
|
+
1.0.5
|
|
23
|
+
=====
|
|
24
|
+
|
|
25
|
+
* fixed Rlists
|
|
26
|
+
|
|
27
|
+
1.0.4
|
|
28
|
+
=====
|
|
29
|
+
|
|
30
|
+
* Minor bug fixes
|
|
31
|
+
* Typos
|
|
32
|
+
* More explicit error messages
|
|
33
|
+
|
|
34
|
+
1.0.3:
|
|
35
|
+
=======
|
|
36
|
+
|
|
37
|
+
* Will print a more meaningfull error if the database file could not be opened
|
|
38
|
+
|
|
39
|
+
1.0.1:
|
|
40
|
+
=======
|
|
41
|
+
* Added functions to free object registeries
|
|
42
|
+
|
|
43
|
+
1.0.0:
|
|
44
|
+
=======
|
|
45
|
+
The begining of a new era
|
rabadb2-2.0/LICENCE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
rabadb2-2.0/MANIFEST.in
ADDED
rabadb2-2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rabaDB2
|
|
3
|
+
Version: 2.0
|
|
4
|
+
Summary: Store, Search, Modify your objects easily. You're welcome.
|
|
5
|
+
Home-page: https://github.com/tariqdaouda/rabaDB
|
|
6
|
+
Author: Tariq Daouda
|
|
7
|
+
Author-email: tariq.daouda@umontreal.ca
|
|
8
|
+
License: ApacheV2.0
|
|
9
|
+
Keywords: NoSQL database ORM sqlite3
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Classifier: Topic :: Database
|
|
17
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
18
|
+
Classifier: Topic :: Database :: Front-Ends
|
|
19
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
21
|
+
License-File: LICENCE
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: keywords
|
|
28
|
+
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: summary
|
|
31
|
+
|
|
32
|
+
rabaDB:
|
|
33
|
+
=======
|
|
34
|
+
rabaDB is a Lightweight Uncomplicated Borderline NoSQL and Schemaless ORM on top of sqlite3.
|
|
35
|
+
All that so you can Store, Search and Modify your objects easily. You're welcome.
|
rabadb2-2.0/README.rst
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
.. image:: http://depsy.org/api/package/pypi/rabaDB/badge.svg
|
|
2
|
+
:alt: depsy
|
|
3
|
+
:target: http://depsy.org/package/python/rabaDB
|
|
4
|
+
|
|
5
|
+
Lightweight Object Persistency for python.
|
|
6
|
+
=========================================================
|
|
7
|
+
|
|
8
|
+
Installation
|
|
9
|
+
-------------
|
|
10
|
+
|
|
11
|
+
.. code:: python
|
|
12
|
+
|
|
13
|
+
pip install rabaDB #for the latest stable version
|
|
14
|
+
|
|
15
|
+
That's it, no need for anything else.
|
|
16
|
+
|
|
17
|
+
What's rabaDB?
|
|
18
|
+
--------------
|
|
19
|
+
|
|
20
|
+
rabaDB is a lightweight, borderline NoSQL, uncomplicated, ORM on top of sqlite3.
|
|
21
|
+
|
|
22
|
+
Basically it means:
|
|
23
|
+
|
|
24
|
+
* *Uncomplicated syntax*
|
|
25
|
+
* *No SQL knowledge needed*: supports queries by example
|
|
26
|
+
* *You can still use SQL* if you want
|
|
27
|
+
* *Lazy and Optimized*: objects are only fully loaded if you need them to be
|
|
28
|
+
* *No dependencies*: super easy installation
|
|
29
|
+
* *Somewhat Schemaless*: you can modify field definitions whenever you want and it will automatically adapt to the new schema
|
|
30
|
+
|
|
31
|
+
Can it be used for "big projects"?
|
|
32
|
+
----------------------------------
|
|
33
|
+
|
|
34
|
+
rabaDB is the backend behind pyGeno_, a python package for genomics and proteomics where it is typically used to store
|
|
35
|
+
whole genomes annonations, along with huge sets of polymorphisms: millions of entries. and it's performing really well.
|
|
36
|
+
|
|
37
|
+
.. _pyGeno: https://github.com/tariqdaouda/pyGeno
|
|
38
|
+
|
|
39
|
+
99% of what you need to know in one Example
|
|
40
|
+
--------------------------------------------
|
|
41
|
+
|
|
42
|
+
.. code:: python
|
|
43
|
+
|
|
44
|
+
#The initialisation
|
|
45
|
+
from rabaDB.rabaSetup import *
|
|
46
|
+
RabaConfiguration('test_namespace', './dbTest_BasicExample.db')
|
|
47
|
+
import rabaDB.Raba as R
|
|
48
|
+
import rabaDB.fields as rf
|
|
49
|
+
|
|
50
|
+
class Human(R.Raba) :
|
|
51
|
+
_raba_namespace = 'test_namespace'
|
|
52
|
+
|
|
53
|
+
#Everything that is not a raba object is primitive
|
|
54
|
+
name = rf.Primitive()
|
|
55
|
+
age = rf.Primitive()
|
|
56
|
+
city = rf.Primitive()
|
|
57
|
+
|
|
58
|
+
#Only Cars can fit into this relation
|
|
59
|
+
cars = rf.Relation('Car')
|
|
60
|
+
|
|
61
|
+
#best friend can only be a human
|
|
62
|
+
bestFriend = rf.RabaObject('Human')
|
|
63
|
+
|
|
64
|
+
def __init__(self) :
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
class Car(R.Raba) :
|
|
68
|
+
_raba_namespace = 'test_namespace'
|
|
69
|
+
|
|
70
|
+
number = rf.Primitive()
|
|
71
|
+
def __init__(self) :
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
if __name__ == '__main__':
|
|
75
|
+
georges = Human()
|
|
76
|
+
georges.name = 'Georges'
|
|
77
|
+
for i in range(10) :
|
|
78
|
+
car = Car()
|
|
79
|
+
car.number = i
|
|
80
|
+
georges.cars.append(car)
|
|
81
|
+
|
|
82
|
+
#saving georges also saves all his cars to the db
|
|
83
|
+
georges.save()
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
What's a namespace?
|
|
88
|
+
-------------------
|
|
89
|
+
|
|
90
|
+
You can think of rabaDB's namespace as independent databases. Each namespace has a name and a file where all the data
|
|
91
|
+
will be saved. Here's how you initialise rabaDb:
|
|
92
|
+
|
|
93
|
+
.. code:: python
|
|
94
|
+
|
|
95
|
+
#The initialisation
|
|
96
|
+
from rabaDB.rabaSetup import *
|
|
97
|
+
RabaConfiguration('test', './dbTest_BasicExample.db')
|
|
98
|
+
|
|
99
|
+
Once you've done that, the configuration is a singleton attached to the namespace. If the filename does not exist
|
|
100
|
+
it will be created for you.
|
|
101
|
+
|
|
102
|
+
You can access it everywhere in you script by simply doing
|
|
103
|
+
|
|
104
|
+
.. code:: python
|
|
105
|
+
|
|
106
|
+
myConf = RabaConfiguration('test')
|
|
107
|
+
|
|
108
|
+
There's also a connection object associated to the namespace
|
|
109
|
+
|
|
110
|
+
.. code:: python
|
|
111
|
+
|
|
112
|
+
myConn = RabaConnnection('test')
|
|
113
|
+
|
|
114
|
+
To know what you can do with that, have a look at the debugging part.
|
|
115
|
+
|
|
116
|
+
Field types
|
|
117
|
+
-----------
|
|
118
|
+
|
|
119
|
+
RabaDB has only **four** variable types:
|
|
120
|
+
|
|
121
|
+
*Primitive:
|
|
122
|
+
- Numbers
|
|
123
|
+
- Strings
|
|
124
|
+
- Serialized objects
|
|
125
|
+
*RabaObject
|
|
126
|
+
- An object whose class derives from Raba.Raba
|
|
127
|
+
*Relation:
|
|
128
|
+
- A list of only a certain type of RabaObject
|
|
129
|
+
*RList:
|
|
130
|
+
- A list of anything
|
|
131
|
+
|
|
132
|
+
Schemaless?
|
|
133
|
+
-----------
|
|
134
|
+
|
|
135
|
+
rabaDB allows you to change the schemas of your classes on the fly. That means that you can add and remove fields
|
|
136
|
+
from your class definitions at any moment during the developement and rabaDB will take care of composing with the
|
|
137
|
+
SQL backend. However keep in mind that whenever you remove a field, all the information relative to that field
|
|
138
|
+
are lost forever.
|
|
139
|
+
|
|
140
|
+
You can even erase whole class definitions from you code, and rabaDB will automatically update the database.
|
|
141
|
+
|
|
142
|
+
Indexation
|
|
143
|
+
-----------
|
|
144
|
+
No problem:
|
|
145
|
+
|
|
146
|
+
.. code:: python
|
|
147
|
+
|
|
148
|
+
Human.ensureIndex('name')
|
|
149
|
+
#even on several fields
|
|
150
|
+
Human.ensureIndex(('name', 'age', 'city'))
|
|
151
|
+
|
|
152
|
+
#To drop an index
|
|
153
|
+
Human.dropIndex('name')
|
|
154
|
+
|
|
155
|
+
Brutal Querying
|
|
156
|
+
---------------
|
|
157
|
+
|
|
158
|
+
You can do things like:
|
|
159
|
+
|
|
160
|
+
.. code:: python
|
|
161
|
+
|
|
162
|
+
georges = Human(name = 'Georges')
|
|
163
|
+
|
|
164
|
+
And rabaDB will try to find a match for you.
|
|
165
|
+
|
|
166
|
+
Querying by example
|
|
167
|
+
-------------------
|
|
168
|
+
Querying by example is done by creating filters, all the conditions inside the same filter are merged by **And**
|
|
169
|
+
and filters between them are merged by **Or**.
|
|
170
|
+
|
|
171
|
+
.. code::
|
|
172
|
+
|
|
173
|
+
f = RabaQuery(SomeClass)
|
|
174
|
+
|
|
175
|
+
f.addFilter(A1, A2, A3)
|
|
176
|
+
f.addFilter(B1, B2)
|
|
177
|
+
|
|
178
|
+
Means: (A1 AND A2 AND A3) OR (B1 AND B2)
|
|
179
|
+
|
|
180
|
+
There are several syntaxes that you can use.
|
|
181
|
+
|
|
182
|
+
.. code:: python
|
|
183
|
+
|
|
184
|
+
from rabaDB.filters import *
|
|
185
|
+
|
|
186
|
+
f = RabaQuery(Human)
|
|
187
|
+
#Or
|
|
188
|
+
f = RabaQuery('Human')
|
|
189
|
+
|
|
190
|
+
f.addFilter(name = "Fela", age = "22")
|
|
191
|
+
#Or the fancier
|
|
192
|
+
f.addFilter({"age >=" : 22, "name like": "fel%"})
|
|
193
|
+
#Or
|
|
194
|
+
f.addFilter(['age = "22"', 'name = Fela'])
|
|
195
|
+
|
|
196
|
+
And then here's how you get your results:
|
|
197
|
+
|
|
198
|
+
.. code:: python
|
|
199
|
+
|
|
200
|
+
for r in f.run() :
|
|
201
|
+
print r
|
|
202
|
+
|
|
203
|
+
You can add an SQL statement at the end
|
|
204
|
+
|
|
205
|
+
.. code:: python
|
|
206
|
+
|
|
207
|
+
for r in f.run(sqlTail = "ORDER By age") :
|
|
208
|
+
print r
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
Querying SQL style
|
|
212
|
+
------------------
|
|
213
|
+
|
|
214
|
+
You can also write your own SQL *WHERE* conditions
|
|
215
|
+
|
|
216
|
+
.. code:: python
|
|
217
|
+
|
|
218
|
+
from rabaDB.filters import *
|
|
219
|
+
|
|
220
|
+
f = RabaQuery(Human)
|
|
221
|
+
|
|
222
|
+
for r in f.runWhere("age = ?, name = ?" , (22, "fela")) :
|
|
223
|
+
print r
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
Getting raw SQL
|
|
227
|
+
----------------
|
|
228
|
+
|
|
229
|
+
By default all querying functions return raba Object, but you can always ask for the raw **SQL** tuple:
|
|
230
|
+
|
|
231
|
+
.. code:: python
|
|
232
|
+
|
|
233
|
+
f.run(raw = True)
|
|
234
|
+
f.runWere(("age = ?, name = ?" , (22, "fela"), raw = True)
|
|
235
|
+
|
|
236
|
+
Supported operators for queries
|
|
237
|
+
--------------------------------
|
|
238
|
+
|
|
239
|
+
The supported operators are: 'LIKE', '=', '<', '>', '=', '>=', '<=', '<>', '!=', 'IS'
|
|
240
|
+
|
|
241
|
+
Yes, but I just want to loop through the results
|
|
242
|
+
------------------------------------------------
|
|
243
|
+
|
|
244
|
+
There are also iterative versions. They have the same interface but they are faster and less memory consuming
|
|
245
|
+
|
|
246
|
+
* f.iterRun
|
|
247
|
+
* f.iterRunWhere
|
|
248
|
+
|
|
249
|
+
And counts?
|
|
250
|
+
----------
|
|
251
|
+
|
|
252
|
+
Here's how you do counts
|
|
253
|
+
|
|
254
|
+
.. code:: python
|
|
255
|
+
|
|
256
|
+
from rabaDB.filters import *
|
|
257
|
+
|
|
258
|
+
f = RabaQuery(Human)
|
|
259
|
+
f.addFilter(age = "22")
|
|
260
|
+
print f.count()
|
|
261
|
+
|
|
262
|
+
Registry
|
|
263
|
+
---------
|
|
264
|
+
|
|
265
|
+
rabaDB keeps an internal registry to ensure a strong object consistency. If you do:
|
|
266
|
+
|
|
267
|
+
.. code:: python
|
|
268
|
+
|
|
269
|
+
georges = Human(name = 'Georges')
|
|
270
|
+
sameGeorges = Human(name = 'Georges')
|
|
271
|
+
|
|
272
|
+
You get two times the same object, every modification you do to georges is also applied to sameGeorges,
|
|
273
|
+
because georges **is** sameGeorges. This rules applies to any form of queries.
|
|
274
|
+
|
|
275
|
+
However keep in mind that the registery will also prevent the garbage collector from erasing raba objects, and
|
|
276
|
+
that can lead to "memory leak"-like situations. The way that is by telling raba that you
|
|
277
|
+
no longer need some objects to be registered:
|
|
278
|
+
|
|
279
|
+
.. code:: python
|
|
280
|
+
|
|
281
|
+
form rabaDB.Raba import *
|
|
282
|
+
|
|
283
|
+
_unregisterRabaObjectInstance(georges)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
Debugging
|
|
287
|
+
---------
|
|
288
|
+
|
|
289
|
+
RabaDB has debugging tools that you can access through the namespace's connection.
|
|
290
|
+
|
|
291
|
+
.. code:: python
|
|
292
|
+
|
|
293
|
+
import rabaDB.rabaSetup
|
|
294
|
+
conn = rabaDB.rabaSetup.RabaConnection("mynamespace")
|
|
295
|
+
|
|
296
|
+
#printing the SQL queries
|
|
297
|
+
conn.enableQueryPrint(True)
|
|
298
|
+
#the part you want to debug
|
|
299
|
+
conn.enableQueryPrint(False)
|
|
300
|
+
#debug: print each SQL querie and asks the permition to continue
|
|
301
|
+
conn.enableDebug(True)
|
|
302
|
+
#the part you want to debug
|
|
303
|
+
conn.enableDebug(False)
|
|
304
|
+
|
|
305
|
+
#record all the queries performed
|
|
306
|
+
conn.enableStats(True, logQueries = True)
|
|
307
|
+
#the part you want to debug
|
|
308
|
+
conn.enableStats(False)
|
|
309
|
+
#a pretty print
|
|
310
|
+
conn.printStats()
|
|
311
|
+
|
|
312
|
+
#when you're done
|
|
313
|
+
conn.eraseStats()
|
|
314
|
+
|
|
315
|
+
Transactions
|
|
316
|
+
------------
|
|
317
|
+
|
|
318
|
+
You can group several queries into one single transaction
|
|
319
|
+
|
|
320
|
+
.. code:: python
|
|
321
|
+
|
|
322
|
+
conn.beginTransaction()
|
|
323
|
+
#a lot of object saving
|
|
324
|
+
conn.endTransaction()
|
|
325
|
+
|
|
326
|
+
Inheritence
|
|
327
|
+
-----------
|
|
328
|
+
|
|
329
|
+
rabaDB fully supports inheritence. Children classes automatically inherit the fields of their parents.
|
|
330
|
+
rabaDB also supports abstract classes, that is to say classes that are never meant to be instanciated and that only
|
|
331
|
+
serve as templates for other classes. Abstract classes have no effect on the database
|
|
332
|
+
|
|
333
|
+
Here's how you declare an abstract class:
|
|
334
|
+
|
|
335
|
+
.. code:: python
|
|
336
|
+
|
|
337
|
+
class pyGenoRabaObject(Raba) :
|
|
338
|
+
|
|
339
|
+
_raba_namespace = "pyGeno"
|
|
340
|
+
_raba_abstract = True # abstractness
|
|
341
|
+
|
|
342
|
+
name = rf.Primitive()
|
|
343
|
+
|