Skip to content

Commit 24f1978

Browse files
Merge pull request #549 from dimitri-yatsenko/master
Add documentation of transactions
2 parents 5a17452 + 29d8853 commit 24f1978

File tree

5 files changed

+167
-4
lines changed

5 files changed

+167
-4
lines changed

datajoint/declare.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ def compile_attribute(line, in_key, foreign_key_sql):
271271
match['default'] = ''
272272
match = {k: v.strip() for k, v in match.items()}
273273
match['nullable'] = match['default'].lower() == 'null'
274-
acceptable_datatype_pattern = r'^(time|date|year|enum|(var)?char|float|real|double|decimal|numeric|' \
275-
r'(tiny|small|medium|big)?int|bool|' \
276-
r'(tiny|small|medium|long)?blob|external|attach)'
277-
if re.match(acceptable_datatype_pattern, match['type'], re.I) is None:
274+
accepted_datatype = r'time|date|year|enum|(var)?char|float|real|double|decimal|numeric|' \
275+
r'(tiny|small|medium|big)?int|bool|' \
276+
r'(tiny|small|medium|long)?blob|external|attach'
277+
if re.match(accepted_datatype, match['type'], re.I) is None:
278278
raise DataJointError('DataJoint does not support datatype "{type}"'.format(**match))
279279

280280
literals = ['CURRENT_TIMESTAMP'] # not to be enclosed in quotes

docs-parts/computation/01-autopopulate_lang1.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414
img = (test.Image & key).fetch1['image']
1515
key['filtered_image'] = myfilter(img)
1616
self.insert(key)
17+
18+
The ``make`` method receives one argument: the dict ``key`` containing the primary key value of an element of :ref:`key source <keysource>` to be worked on.

docs-parts/intro/Releases_lang1.rst

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
0.11.1 -- Nov 15, 2018
2+
----------------------
3+
* Fix ordering of attributes in proj (#483 and #516)
4+
* Prohibit direct insert into auto-populated tables (#511)
5+
6+
0.11.0 -- Oct 25, 2018
7+
----------------------
8+
* Full support of dependencies with renamed attributes using projection syntax (#300, #345, #436, #506, #507)
9+
* Rename internal class and module names to comply with terminology in documentation (#494, #500)
10+
* Full support of secondary indexes (#498, 500)
11+
* ERD no longer shows numbers in nodes corresponding to derived dependencies (#478, #500)
12+
* Full support of unique and nullable dependencies (#254, #301, #493, #495, #500)
13+
* Improve memory management in ``populate`` (#461, #486)
14+
* Fix query errors and redundancies (#456, #463, #482)
15+
16+
0.10.1 -- Aug 28, 2018
17+
-----------------------
18+
* Fix ERD Tooltip message (#431)
19+
* Networkx 2.0 support (#443)
20+
* Fix insert from query with skip_duplicates=True (#451)
21+
* Sped up queries (#458)
22+
* Bugfix in restriction of the form (A & B) * B (#463)
23+
* Improved error messages (#466)
24+
25+
0.10.0 -- Jan 10, 2018
26+
----------------------
27+
* Deletes are more efficient (#424)
28+
* ERD shows table definition on tooltip hover in Jupyter (#422)
29+
* S3 external storage
30+
* Garbage collection for external sorage
31+
* Most operators and methods of tables can be invoked as class methods rather than instance methods (#407)
32+
* The schema decorator object no longer requires locals() to specify the context
33+
* Compatibility with pymysql 0.8.0+
34+
* More efficient loading of dependencies (#403)
35+
36+
0.9.0 -- Nov 17, 2017
37+
---------------------
38+
* Made graphviz installation optional
39+
* Implement file-based external storage
40+
* Implement union operator +
41+
* Implement file-based external storage
42+
43+
0.8.0 -- Jul 26, 2017
44+
---------------------
45+
Documentation and tutorials available at https://docs.datajoint.io and https://tutorials.datajoint.io
46+
* improved the ERD graphics and features using the graphviz libraries (#207, #333)
47+
* improved password handling logic (#322, #321)
48+
* the use of the ``contents`` property to populate tables now only works in ``dj.Lookup`` classes (#310).
49+
* allow suppressing the display of size of query results through the ``show_tuple_count`` configuration option (#309)
50+
* implemented renamed foreign keys to spec (#333)
51+
* added the ``limit`` keyword argument to populate (#329)
52+
* reduced the number of displayed messages (#308)
53+
* added ``size_on_disk`` property for dj.Schema() objects (#323)
54+
* job keys are entered in the jobs table (#316, #243)
55+
* simplified the ``fetch`` and ``fetch1`` syntax, deprecating the ``fetch[...]`` syntax (#319)
56+
* the jobs tables now store the connection ids to allow identifying abandoned jobs (#288, #317)
57+
58+
0.5.0 (#298) -- Mar 8, 2017
59+
---------------------------
60+
* All fetched integers are now 64-bit long and all fetched floats are double precision.
61+
* Added ``dj.create_virtual_module``
62+
63+
0.4.10 (#286) -- Feb 6, 2017
64+
----------------------------
65+
* Removed Vagrant and Readthedocs support
66+
* Explicit saving of configuration (issue #284)
67+
68+
0.4.9 (#285) -- Feb 2, 2017
69+
---------------------------
70+
* Fixed setup.py for pip install
71+
72+
0.4.7 (#281) -- Jan 24, 2017
73+
----------------------------
74+
* Fixed issues related to order of attributes in projection.
75+
76+
0.4.6 (#277) -- Dec 22, 2016
77+
----------------------------
78+
* Proper handling of interruptions during populate
79+
80+
0.4.5 (#274) -- Dec 20, 2016
81+
----------------------------
82+
* Populate reports how many keys remain to be populated at the start.
83+
84+
0.4.3 (#271) -- Dec 6, 2016
85+
----------------------------
86+
* Fixed aggregation issues (#270)
87+
* datajoint no longer attempts to connect to server at import time
88+
* dropped support of view (reversed #257)
89+
* more elegant handling of insufficient privileges (#268)
90+
91+
0.4.2 (#267) -- Dec 6, 2016
92+
----------------------------
93+
* improved table appearance in Jupyter
94+
95+
0.4.1 (#266) -- Oct 28, 2016
96+
----------------------------
97+
* bugfix for very long error messages
98+
99+
0.3.9 -- Sep 27, 2016
100+
---------------------
101+
* Added support for datatype ``YEAR``
102+
* Fixed issues with ``dj.U`` and the ``aggr`` operator (#246, #247)
103+
104+
0.3.8 -- Aug 2, 2016
105+
---------------------
106+
* added the ``_update`` method in ``base_relation``. It allows updating values in existing tuples.
107+
* bugfix in reading values of type double. Previously it was cast as float32.
108+
109+
0.3.7 -- Jul 31, 2016
110+
----------------------
111+
* added parameter ``ignore_extra_fields`` in ``insert``
112+
* ``insert(..., skip_duplicates=True)`` now relies on ``SELECT IGNORE``. Previously it explicitly checked if tuple already exists.
113+
* table previews now include blob attributes displaying the string <BLOB>
114+
115+
0.3.6 -- Jul 30, 2016
116+
----------------------
117+
* bugfix in ``schema.spawn_missing_classes``. Previously, spawned part classes would not show in ERDs.
118+
* dj.key now causes fetch to return as a list of dicts. Previously it was a recarray.
119+
120+
0.3.5
121+
-----
122+
* ``dj.set_password()`` now asks for user confirmation before changing the password.
123+
* fixed issue #228
124+
125+
0.3.4
126+
-----
127+
* Added method the ``ERD.add_parts`` method, which adds the part tables of all tables currently in the ERD.
128+
* ``ERD() + arg`` and ``ERD() - arg`` can now accept relation classes as arg.
129+
130+
0.3.3
131+
-----
132+
* Suppressed warnings (redirected them to logging). Previoiusly, scipy would throw warnings in ERD, for example.
133+
* Added ERD.from_sequence as a shortcut to combining the ERDs of multiple sources
134+
* ERD() no longer text the context argument.
135+
* ERD.draw() now takes an optional context argument. By default uses the caller's locals.
136+
137+
0.3.2
138+
-----
139+
* Fixed issue #223: ``insert`` can insert relations without fetching.
140+
* ERD() now takes the ``context`` argument, which specifies in which context to look for classes. The default is taken from the argument (schema or relation).
141+
* ERD.draw() no longer has the ``prefix`` argument: class names are shown as found in the context.

docs-parts/intro/empty.txt

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Transactions are formed using the ``transaction`` property of the connection object.
2+
The connection object may be obtained from any table object.
3+
The ``transaction`` property can then be used as a context manager in Python's ``with`` statement.
4+
5+
For example, the following code inserts matching entries for the master table ``Session`` and its part table ``Session.Experimenter``.
6+
7+
.. code-block:: python
8+
9+
# get the connection object
10+
connection = Session.connection
11+
12+
# insert Session and Session.Experimenter entries in a transaction
13+
with connection.transaction:
14+
key = {'subject_id': animal_id, 'session_time': session_time}
15+
Session.insert1({**key, 'brain_region':region, 'cortical_layer':layer})
16+
Session.Experimenter.insert1({**key, 'experimenter': username})
17+
18+
Here, to external observers, both inserts will take effect together upon exiting from the ``with`` block or will not have any effect at all.
19+
For example, if the second insert fails due to an error, the first insert will be rolled back.
20+

0 commit comments

Comments
 (0)