diff --git a/.gitignore b/.gitignore index 7b6b58d7d..af0a838bf 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ notebook __main__.py jupyter_custom.js apk_requirements.txt -.eggs \ No newline at end of file +.eggs +*.code-workspace diff --git a/0.13/404.html b/0.13/404.html new file mode 100644 index 000000000..89854be20 --- /dev/null +++ b/0.13/404.html @@ -0,0 +1,1066 @@ + + + +
+ + + + + + + + + + + +jobs argument for multiprocessing PR #997ExternalTable.delete should not remove row on error (#953) PR #956s3.py (#952) PR #955DISTINCT clause and GROUP_BY (#914) PR #963ONLY_FULL_GROUP_BY (#916) PR #965QueryExpressions (#951) PR #966~jobs.error_stack from blob to mediumblob to allow error stacks >64kB in jobs (#984) PR #986make() in populate() PR #971setuptools_certificate dependency to new name otumatdj.Connection throw error due to missing host_input (#895) PR #907None as an alias for IS NULL comparison in dict restrictions (#824) PR #893schema.list_tables() is not topologically sorted (#838) PR #893.update1 to update a row in the table with new values (#867) PR #763, #889@ and ^ (#785) PR #754dj.key_hash alias to dj.hash.key_hash (#804) PR #862fetch1('KEY') when dj.config['fetch_format']='frame' set (#876) PR #880, #878_update. PR #889purge_query_cache utility. PR #889dj.config['fetch_format']="frame". (#876) PR #880schema.save. (#821) PR #833schema.list_tables. (#838) PR #844order_by to dj.kill (#668, #779) PR #775, #783_update to allow nullable updates for strings/date (#664) PR #760kill_quick and expand display to include host (#740) PR #741index field (#666) PR #776delete_external_files=True does not remove from S3 (#686) PR #781fetch_format='frame' PR #774dj.schema into dj.schemas. dj.schema remains an alias for class dj.Schema. (#731) PR #732dj.create_virtual_module is now called dj.VirtualModule (#731) PR #732KeyError on failed connection (#716) PR #725suppress_errors does not suppress loss of connection error (#720) PR #721serial data type in declarations: alias for bigint unsigned auto_increment PR #713dj.config['stores']['<store>']['location'] (#692) PR #693as_dict=True for specified attributes. (#595) PR #593proj: query_expression.proj(.., '-movie') (#499) PR #578conda install datajoint via conda-forge channel (#293)dj.conn() accepts a port keyword argument (#563) PR #571query_expr.fetch("KEY", as_dict=False) returns results as np.recarray(#414) PR #574dj.ERD is now called dj.Diagram (#255, #546) PR #565dj.Diagram underlines "distinguished" classes (#378) PR #557fetch (#459, #537) PR #534fetch (#541) PR #534populate (#461, #486)Documentation and tutorials available at https://docs.datajoint.io and https://tutorials.datajoint.io
+* improved the ERD graphics and features using the graphviz libraries (#207, #333)
+* improved password handling logic (#322, #321)
+* the use of the contents property to populate tables now only works in dj.Lookup classes (#310).
+* allow suppressing the display of size of query results through the show_tuple_count configuration option (#309)
+* implemented renamed foreign keys to spec (#333)
+* added the limit keyword argument to populate (#329)
+* reduced the number of displayed messages (#308)
+* added size_on_disk property for dj.Schema() objects (#323)
+* job keys are entered in the jobs table (#316, #243)
+* simplified the fetch and fetch1 syntax, deprecating the fetch[...] syntax (#319)
+* the jobs tables now store the connection ids to allow identifying abandoned jobs (#288, #317)
dj.create_virtual_moduleYEARdj.U and the aggr operator (#246, #247)_update method in base_relation. It allows updating values in existing tuples.ignore_extra_fields in insertinsert(..., skip_duplicates=True) now relies on SELECT IGNORE. Previously it explicitly checked if tuple already exists.schema.spawn_missing_classes. Previously, spawned part classes would not show in ERDs.dj.set_password() now asks for user confirmation before changing the password.ERD.add_parts method, which adds the part tables of all tables currently in the ERD.ERD() + arg and ERD() - arg can now accept table classes as arg.insert can insert relations without fetching.context argument, which specifies in which context to look for classes. The default is taken from the argument (schema or table).prefix argument: class names are shown as found in the context.DataJoint for Python is a framework for building data piplines using MySQL databases +to represent pipeline structure and bulk storage systems for large objects. +DataJoint is built on the foundation of the relational data model and prescribes a +consistent method for organizing, populating, and querying data.
+The DataJoint data model is described in https://arxiv.org/abs/1807.11104
+DataJoint is free software under the LGPL License. In addition, we request +that any use of DataJoint leading to a publication be acknowledged in the publication.
+Please cite:
+- http://biorxiv.org/content/early/2015/11/14/031658 + - http://dx.doi.org/10.1101/031658
+ + + +AttributeAdapter
+
+
+¶Base class for adapter objects for user-defined attribute types.
+ + +datajoint/attribute_adapter.py6 + 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 | |
attribute_type()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +a supported DataJoint attribute type to use; e.g. "longblob", "blob@store" |
+
datajoint/attribute_adapter.py11 +12 +13 +14 +15 +16 | |
get(value)
+
+¶convert value retrieved from the the attribute in a table into the adapted type
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
value |
+ + | +value from the database |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +object of the adapted type |
+
datajoint/attribute_adapter.py18 +19 +20 +21 +22 +23 +24 +25 +26 | |
put(obj)
+
+¶convert an object of the adapted type into a value that DataJoint can store in a table attribute
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
obj |
+ + | +an object of the adapted type |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +value to store in the database |
+
datajoint/attribute_adapter.py28 +29 +30 +31 +32 +33 +34 +35 | |
key_hash(mapping)
+
+¶32-byte hash of the mapping's key values sorted by the key name. +This is often used to convert a long primary key value into a shorter hash. +For example, the JobTable in datajoint.jobs uses this function to hash the primary key of autopopulated tables.
+ +datajoint/hash.py7 + 8 + 9 +10 +11 +12 +13 +14 +15 +16 | |
migrate_dj011_external_blob_storage_to_dj012(migration_schema, store)
+
+¶Utility function to migrate external blob data from 0.11 to 0.12.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
migration_schema |
+ + | +string of target schema to be migrated |
+ + required + | +
store |
+ + | +string of target dj.config['store'] to be migrated |
+ + required + | +
datajoint/migrate.py7 + 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 | |
DataJointError
+
+
+¶
+ Bases: Exception
Base class for errors specific to DataJoint internal operation.
+ + +datajoint/errors.py14 +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 | |
suggest(*args)
+
+¶regenerate the exception with additional arguments
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
args |
+ + | +addition arguments |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +a new exception of the same type with the additional arguments |
+
datajoint/errors.py34 +35 +36 +37 +38 +39 +40 +41 | |
key
+
+
+¶object that allows requesting the primary key as an argument in expression.fetch() +The string "KEY" can be used instead of the class key
+ + +datajoint/fetch.py18 +19 +20 +21 +22 +23 +24 | |
AndList
+
+
+¶
+ Bases: list
A list of conditions to by applied to a query expression by logical conjunction: the +conditions are AND-ed. All other collections (lists, sets, other entity sets, etc) are +applied by logical disjunction (OR).
+Example: +expr2 = expr & dj.AndList((cond1, cond2, cond3)) +is equivalent to +expr2 = expr & cond1 & cond2 & cond3
+ + +datajoint/condition.py23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 | |
kill(restriction=None, connection=None, order_by=None)
+
+¶view and kill database connections.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
restriction |
+ + | +restriction to be applied to processlist |
+
+ None
+ |
+
connection |
+ + | +a datajoint.Connection object. Default calls datajoint.conn() |
+
+ None
+ |
+
order_by |
+ + | +order by a single attribute or the list of attributes. defaults to 'id'. Restrictions are specified as strings and can involve any of the attributes of information_schema.processlist: ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO. Examples: dj.kill('HOST LIKE "%compute%"') lists only connections from hosts containing "compute". dj.kill('TIME > 600') lists only connections in their current state for more than 10 minutes |
+
+ None
+ |
+
datajoint/admin.py28 +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 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 | |
Schema
+
+
+¶A schema object is a decorator for UserTable classes that binds them to their database.
+It also specifies the namespace context in which other UserTable classes are defined.
datajoint/schemas.py36 + 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 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 | |
activate(schema_name=None, *, connection=None, create_schema=None, create_tables=None, add_objects=None)
+
+¶Associate database schema schema_name. If the schema does not exist, attempt to
+create it on the server.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
schema_name |
+ + | +the database schema to associate. schema_name=None is used to assert that the schema has already been activated. |
+
+ None
+ |
+
connection |
+ + | +Connection object. Defaults to datajoint.conn(). |
+
+ None
+ |
+
create_schema |
+ + | +If False, do not create the schema and raise an error if missing. |
+
+ None
+ |
+
create_tables |
+ + | +If False, do not create tables and raise errors when attempting to access missing tables. |
+
+ None
+ |
+
add_objects |
+ + | +a mapping with additional objects to make available to the context in which table classes are declared. |
+
+ None
+ |
+
datajoint/schemas.py83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 | |
size_on_disk()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +size of the entire schema in bytes |
+
datajoint/schemas.py266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 | |
spawn_missing_classes(context=None)
+
+¶Creates the appropriate python user table classes from tables in the schema and places them +in the context.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
context |
+ + | +alternative context to place the missing classes into, e.g. locals() |
+
+ None
+ |
+
datajoint/schemas.py283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 | |
drop(force=False)
+
+¶Drop the associated schema if it exists
+ +datajoint/schemas.py343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 | |
exists()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +true if the associated schema exists on the server |
+
datajoint/schemas.py377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 | |
jobs()
+
+
+ property
+
+
+¶schema.jobs provides a view of the job reservation table for the schema
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +jobs table |
+
datajoint/schemas.py392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 | |
save(python_filename=None)
+
+¶Generate the code for a module that recreates the schema. +This method is in preparation for a future release and is not officially supported.
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +a string containing the body of a complete Python module defining this schema. |
+
datajoint/schemas.py409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 | |
list_tables()
+
+¶Return a list of all tables in the schema except tables with ~ in first character such +as ~logs and ~job
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +A list of table names from the database schema. |
+
datajoint/schemas.py476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 | |
Not
+
+
+¶invert restriction
+ + +datajoint/condition.py43 +44 +45 +46 +47 | |
Table
+
+
+¶
+ Bases: QueryExpression
Table is an abstract class that represents a table in the schema. +It implements insert and delete methods and inherits query functionality. +To make it a concrete class, override the abstract properties specifying the connection, +table name, database, and definition.
+ + +datajoint/table.py56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 +930 +931 +932 +933 +934 +935 +936 +937 +938 +939 +940 +941 +942 +943 +944 +945 +946 +947 +948 | |
declare(context=None)
+
+¶Declare the table in the schema based on self.definition.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
context |
+ + | +the context for foreign key resolution. If None, foreign keys are not allowed. |
+
+ None
+ |
+
datajoint/table.py82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 | |
alter(prompt=True, context=None)
+
+¶Alter the table definition from self.definition
+ +datajoint/table.py107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 | |
from_clause()
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the FROM clause of SQL SELECT statements. |
+
datajoint/table.py147 +148 +149 +150 +151 | |
get_select_fields(select_fields=None)
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the selected attributes from the SQL SELECT statement. |
+
datajoint/table.py153 +154 +155 +156 +157 +158 +159 | |
parents(primary=None, as_objects=False, foreign_key_info=False)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
primary |
+ + | +if None, then all parents are returned. If True, then only foreign keys composed of primary key attributes are considered. If False, return foreign keys including at least one secondary attribute. |
+
+ None
+ |
+
as_objects |
+ + | +if False, return table names. If True, return table objects. |
+
+ False
+ |
+
foreign_key_info |
+ + | +if True, each element in result also includes foreign key info. |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of parents as table names or table objects with (optional) foreign key information. |
+
datajoint/table.py161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 | |
children(primary=None, as_objects=False, foreign_key_info=False)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
primary |
+ + | +if None, then all children are returned. If True, then only foreign keys composed of primary key attributes are considered. If False, return foreign keys including at least one secondary attribute. |
+
+ None
+ |
+
as_objects |
+ + | +if False, return table names. If True, return table objects. |
+
+ False
+ |
+
foreign_key_info |
+ + | +if True, each element in result also includes foreign key info. |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of children as table names or table objects with (optional) foreign key information. |
+
datajoint/table.py183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 | |
descendants(as_objects=False)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
as_objects |
+ + | +False - a list of table names; True - a list of table objects. |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of tables descendants in topological order. |
+
datajoint/table.py205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 | |
ancestors(as_objects=False)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
as_objects |
+ + | +False - a list of table names; True - a list of table objects. |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of tables ancestors in topological order. |
+
datajoint/table.py217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 | |
parts(as_objects=False)
+
+¶return part tables either as entries in a dict with foreign key informaiton or a list of objects
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
as_objects |
+ + | +if False (default), the output is a dict describing the foreign keys. If True, return table objects. |
+
+ False
+ |
+
datajoint/table.py229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 | |
is_declared()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +True is the table is declared in the schema. |
+
datajoint/table.py242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 | |
full_table_name()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +full table name in the schema |
+
datajoint/table.py256 +257 +258 +259 +260 +261 | |
update1(row)
+
+¶update1 updates one existing entry in the table.
+Caution: In DataJoint the primary modes for data manipulation is to insert and
+delete entire records since referential integrity works on the level of records,
+not fields. Therefore, updates are reserved for corrective operations outside of main
+workflow. Use UPDATE methods sparingly with full awareness of potential violations of
+assumptions.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
row |
+ + | +a |
+ + required + | +
datajoint/table.py277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 | |
insert1(row, **kwargs)
+
+¶Insert one data record into the table. For kwargs, see insert().
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
row |
+ + | +a numpy record, a dict-like object, or an ordered sequence to be inserted as one row. |
+ + required + | +
datajoint/table.py328 +329 +330 +331 +332 +333 +334 +335 | |
insert(rows, replace=False, skip_duplicates=False, ignore_extra_fields=False, allow_direct_insert=None)
+
+¶Insert a collection of rows.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
rows |
+ + | +An iterable where an element is a numpy record, a dict-like object, a pandas.DataFrame, a sequence, or a query expression with the same heading as self. |
+ + required + | +
replace |
+ + | +If True, replaces the existing tuple. |
+
+ False
+ |
+
skip_duplicates |
+ + | +If True, silently skip duplicate inserts. |
+
+ False
+ |
+
ignore_extra_fields |
+ + | +If False, fields that are not in the heading raise error. |
+
+ False
+ |
+
allow_direct_insert |
+ + | +applies only in auto-populated tables. If False (default), insert are allowed only from inside the make callback. Example: >>> Table.insert([ >>> dict(subject_id=7, species="mouse", date_of_birth="2014-09-01"), >>> dict(subject_id=8, species="mouse", date_of_birth="2014-09-02")]) |
+
+ None
+ |
+
datajoint/table.py337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 | |
delete_quick(get_count=False)
+
+¶Deletes the table without cascading and without user prompt. +If this table has populated dependent tables, this will fail.
+ +datajoint/table.py448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 | |
delete(transaction=True, safemode=None, force_parts=False)
+
+¶Deletes the contents of the table and its dependent tables, recursively.
+Args:
+ transaction: If True, use of the entire delete becomes an atomic transaction.
+ This is the default and recommended behavior. Set to False if this delete is
+ nested within another transaction.
+ safemode: If True, prohibit nested transactions and prompt to confirm. Default
+ is dj.config['safemode'].
+ force_parts: Delete from parts even when not deleting from their masters.
Returns: + Number of deleted rows (excluding those from dependent tables).
+Raises: + DataJointError: Delete exceeds maximum number of delete attempts. + DataJointError: When deleting within an existing transaction. + DataJointError: Deleting a part table before its master.
+ +datajoint/table.py463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 | |
drop_quick()
+
+¶Drops the table without cascading to dependent tables and without user prompt.
+ +datajoint/table.py614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 | |
drop()
+
+¶Drop the table and all tables that reference it, recursively. +User is prompted for confirmation if config['safemode'] is set to True.
+ +datajoint/table.py628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 | |
size_on_disk()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +size of data and indices in bytes on the storage device |
+
datajoint/table.py664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 | |
describe(context=None, printout=True)
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the definition string for the query using DataJoint DDL. |
+
datajoint/table.py682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 | |
Diagram
+
+
+¶
+ Bases: nx.DiGraph
Entity relationship diagram.
+Usage:
+++++++diag = Diagram(source)
+
source can be a base table object, a base table class, a schema, or a module that has a schema.
+++++++diag.draw()
+
draws the diagram using pyplot
+diag1 + diag2 - combines the two diagrams. +diag + n - expands n levels of successors +diag - n - expands n levels of predecessors +Thus dj.Diagram(schema.Table)+1-1 defines the diagram of immediate ancestors and descendants of schema.Table
+Note that diagram + 1 - 1 may differ from diagram - 1 + 1 and so forth. +Only those tables that are loaded in the connection object are displayed
+ + +datajoint/diagram.py73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 | |
from_sequence(sequence)
+
+
+ classmethod
+
+
+¶The join Diagram for all objects in sequence
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
sequence |
+ + | +a sequence (e.g. list, tuple) |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +Diagram(arg1) + ... + Diagram(argn) |
+
datajoint/diagram.py146 +147 +148 +149 +150 +151 +152 +153 +154 | |
add_parts()
+
+¶Adds to the diagram the part tables of tables already included in the diagram
+ +Returns:
+| Type | +Description | +
|---|---|
| + | ++ |
datajoint/diagram.py156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 | |
topological_sort()
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +list of nodes in topological order |
+
datajoint/diagram.py183 +184 +185 +186 +187 +188 +189 +190 +191 | |
MatCell
+
+
+¶
+ Bases: np.ndarray
a numpy ndarray representing a Matlab cell array
+ + +datajoint/blob.py73 +74 +75 +76 | |
MatStruct
+
+
+¶
+ Bases: np.recarray
numpy.recarray representing a Matlab struct array
+ + +datajoint/blob.py79 +80 +81 +82 | |
conn(host=None, user=None, password=None, *, init_fun=None, reset=False, use_tls=None)
+
+¶Returns a persistent connection object to be shared by multiple modules. +If the connection is not yet established or reset=True, a new connection is set up. +If connection information is not provided, it is taken from config which takes the +information from dj_local_conf.json. If the password is not specified in that file +datajoint prompts for the password.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
host |
+ + | +hostname |
+
+ None
+ |
+
user |
+ + | +mysql user |
+
+ None
+ |
+
password |
+ + | +mysql password |
+
+ None
+ |
+
init_fun |
+ + | +initialization function |
+
+ None
+ |
+
reset |
+ + | +whether the connection should be reset or not |
+
+ False
+ |
+
use_tls |
+ + | +TLS encryption option. Valid options are: True (required), False (required no TLS), None (TLS prefered, default), dict (Manually specify values per https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#encrypted-connection-options). |
+
+ None
+ |
+
datajoint/connection.py100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 | |
Manual
+
+
+¶
+ Bases: UserTable
Inherit from this class if the table's values are entered manually.
+ + +datajoint/user_tables.py133 +134 +135 +136 +137 +138 +139 | |
Lookup
+
+
+¶
+ Bases: UserTable
Inherit from this class if the table's values are for lookup. This is +currently equivalent to defining the table as Manual and serves semantic +purposes only.
+ + +datajoint/user_tables.py142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 | |
Imported
+
+
+¶
+ Bases: UserTable, AutoPopulate
Inherit from this class if the table's values are imported from external data sources.
+The inherited class must at least provide the function _make_tuples.
datajoint/user_tables.py155 +156 +157 +158 +159 +160 +161 +162 | |
Connection
+
+
+¶A dj.Connection object manages a connection to a database server. +It also catalogues modules, schemas, tables, and their dependencies (foreign keys).
+Most of the parameters below should be set in the local configuration file.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
host |
+ + | +host name, may include port number as hostname:port, in which case it overrides the value in port |
+ + required + | +
user |
+ + | +user name |
+ + required + | +
password |
+ + | +password |
+ + required + | +
port |
+ + | +port number |
+
+ None
+ |
+
init_fun |
+ + | +connection initialization function (SQL) |
+
+ None
+ |
+
use_tls |
+ + | +TLS encryption option |
+
+ None
+ |
+
datajoint/connection.py159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 | |
connect()
+
+¶Connect to the database server.
+ +datajoint/connection.py212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 | |
set_query_cache(query_cache=None)
+
+¶When query_cache is not None, the connection switches into the query caching mode, which entails: +1. Only SELECT queries are allowed. +2. The results of queries are cached under the path indicated by dj.config['query_cache'] +3. query_cache is a string that differentiates different cache states.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
query_cache |
+ + | +a string to initialize the hash for query results |
+
+ None
+ |
+
datajoint/connection.py246 +247 +248 +249 +250 +251 +252 +253 +254 +255 | |
purge_query_cache()
+
+¶Purges all query cache.
+ +datajoint/connection.py257 +258 +259 +260 +261 +262 +263 +264 +265 | |
ping()
+
+¶Ping the connection or raises an exception if the connection is closed.
+ +datajoint/connection.py274 +275 +276 | |
is_connected()
+
+
+ property
+
+
+¶Return true if the object is connected to the database server.
+ +datajoint/connection.py278 +279 +280 +281 +282 +283 +284 +285 | |
query(query, args=(), *, as_dict=False, suppress_warnings=True, reconnect=None)
+
+¶Execute the specified query and return the tuple generator (cursor).
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
query |
+ + | +SQL query |
+ + required + | +
args |
+ + | +additional arguments for the client.cursor |
+
+ ()
+ |
+
as_dict |
+ + | +If as_dict is set to True, the returned cursor objects returns query results as dictionary. |
+
+ False
+ |
+
suppress_warnings |
+ + | +If True, suppress all warnings arising from underlying query library |
+
+ True
+ |
+
reconnect |
+ + | +when None, get from config, when True, attempt to reconnect if disconnected |
+
+ None
+ |
+
datajoint/connection.py298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 | |
get_user()
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the user name and host name provided by the client to the server. |
+
datajoint/connection.py362 +363 +364 +365 +366 | |
in_transaction()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +True if there is an open transaction. |
+
datajoint/connection.py369 +370 +371 +372 +373 +374 +375 | |
start_transaction()
+
+¶Starts a transaction error.
+ +datajoint/connection.py377 +378 +379 +380 +381 +382 +383 +384 +385 | |
cancel_transaction()
+
+¶Cancels the current transaction and rolls back all changes made during the transaction.
+ +datajoint/connection.py387 +388 +389 +390 +391 +392 +393 | |
commit_transaction()
+
+¶Commit all changes made during the transaction and close it.
+ +datajoint/connection.py395 +396 +397 +398 +399 +400 +401 +402 | |
transaction()
+
+
+ property
+
+
+¶Context manager for transactions. Opens an transaction and closes it after the with statement. +If an error is caught during the transaction, the commits are automatically rolled back. +All errors are raised again.
+Example:
+++ +++++import datajoint as dj +with dj.conn().transaction as conn: + # transaction is open here
+
datajoint/connection.py405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 | |
Computed
+
+
+¶
+ Bases: UserTable, AutoPopulate
Inherit from this class if the table's values are computed from other tables in the schema.
+The inherited class must at least provide the function _make_tuples.
datajoint/user_tables.py165 +166 +167 +168 +169 +170 +171 +172 | |
Part
+
+
+¶
+ Bases: UserTable
Inherit from this class if the table's values are details of an entry in another table +and if this table is populated by the other table. For example, the entries inheriting from +dj.Part could be single entries of a matrix, while the parent table refers to the entire matrix. +Part tables are implemented as classes inside classes.
+ + +datajoint/user_tables.py175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 | |
delete(force=False)
+
+¶unless force is True, prohibits direct deletes from parts.
+ +datajoint/user_tables.py220 +221 +222 +223 +224 +225 +226 +227 +228 +229 | |
drop(force=False)
+
+¶unless force is True, prohibits direct deletes from parts.
+ +datajoint/user_tables.py231 +232 +233 +234 +235 +236 +237 +238 +239 +240 | |
VirtualModule
+
+
+¶
+ Bases: types.ModuleType
A virtual module imitates a Python module representing a DataJoint schema from table definitions in the database. +It declares the schema objects and a class for each table.
+ + +datajoint/schemas.py493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 | |
list_schemas(connection=None)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
connection |
+ + | +a dj.Connection object |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of all accessible schemas on the server |
+
datajoint/schemas.py534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 | |
U
+
+
+¶dj.U objects are the universal sets representing all possible values of their attributes. +dj.U objects cannot be queried on their own but are useful for forming some queries. +dj.U('attr1', ..., 'attrn') represents the universal set with the primary key attributes attr1 ... attrn. +The universal set is the set of all possible combinations of values of the attributes. +Without any attributes, dj.U() represents the set with one element that has no attributes.
+Restriction:
+dj.U can be used to enumerate unique combinations of values of attributes from other expressions.
+The following expression yields all unique combinations of contrast and brightness found in the stimulus set:
++++++dj.U('contrast', 'brightness') & stimulus
+
Aggregation:
+In aggregation, dj.U is used for summary calculation over an entire set:
+The following expression yields one element with one attribute s containing the total number of elements in
+query expression expr:
++++++dj.U().aggr(expr, n='count(*)')
+
The following expressions both yield one element containing the number n of distinct values of attribute attr in
+query expressio expr.
++++++dj.U().aggr(expr, n='count(distinct attr)') +dj.U().aggr(dj.U('attr').aggr(expr), 'n=count(*)')
+
The following expression yields one element and one attribute s containing the sum of values of attribute attr
+over entire result set of expression expr:
++++++dj.U().aggr(expr, s='sum(attr)')
+
The following expression yields the set of all unique combinations of attributes attr1, attr2 and the number of
+their occurrences in the result set of query expression expr.
++++++dj.U(attr1,attr2).aggr(expr, n='count(*)')
+
Joins:
+If expression expr has attributes 'attr1' and 'attr2', then expr * dj.U('attr1','attr2') yields the same result
+as expr but attr1 and attr2 are promoted to the the primary key. This is useful for producing a join on
+non-primary key attributes.
+For example, if attr is in both expr1 and expr2 but not in their primary keys, then expr1 * expr2 will throw
+an error because in most cases, it does not make sense to join on non-primary key attributes and users must first
+rename attr in one of the operands. The expression dj.U('attr') * rel1 * rel2 overrides this constraint.
datajoint/expression.py812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 | |
join(other, left=False)
+
+¶Joining U with a query expression has the effect of promoting the attributes of U to +the primary key of the other query expression.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
other |
+ + | +the other query expression to join with. |
+ + required + | +
left |
+ + | +ignored. dj.U always acts as if left=False |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +a copy of the other query expression with the primary key extended. |
+
datajoint/expression.py881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 | |
aggr(group, **named_attributes)
+
+¶Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
+has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of group.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
group |
+ + | +The query expression to be aggregated. |
+ + required + | +
named_attributes |
+ + | +computations of the form new_attribute="sql expression on attributes of group" |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +The derived query expression |
+
datajoint/expression.py912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 | |
FreeTable
+
+
+¶
+ Bases: Table
A base table without a dedicated class. Each instance is associated with a table +specified by full_table_name.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
conn |
+ + | +a dj.Connection object |
+ + required + | +
full_table_name |
+ + | +in format |
+ + required + | +
datajoint/table.py1005 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +1030 +1031 +1032 +1033 | |
kill(restriction=None, connection=None, order_by=None)
+
+¶view and kill database connections.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
restriction |
+ + | +restriction to be applied to processlist |
+
+ None
+ |
+
connection |
+ + | +a datajoint.Connection object. Default calls datajoint.conn() |
+
+ None
+ |
+
order_by |
+ + | +order by a single attribute or the list of attributes. defaults to 'id'. Restrictions are specified as strings and can involve any of the attributes of information_schema.processlist: ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO. Examples: dj.kill('HOST LIKE "%compute%"') lists only connections from hosts containing "compute". dj.kill('TIME > 600') lists only connections in their current state for more than 10 minutes |
+
+ None
+ |
+
datajoint/admin.py28 +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 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 | |
kill_quick(restriction=None, connection=None)
+
+¶Kill database connections without prompting. Returns number of terminated connections.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
restriction |
+ + | +restriction to be applied to processlist |
+
+ None
+ |
+
connection |
+ + | +a datajoint.Connection object. Default calls datajoint.conn() Restrictions are specified as strings and can involve any of the attributes of information_schema.processlist: ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO. Examples: dj.kill('HOST LIKE "%compute%"') terminates connections from hosts containing "compute". |
+
+ None
+ |
+
datajoint/admin.py87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 | |
AttributeAdapter
+
+
+¶Base class for adapter objects for user-defined attribute types.
+ + +datajoint/attribute_adapter.py6 + 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 | |
attribute_type()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +a supported DataJoint attribute type to use; e.g. "longblob", "blob@store" |
+
datajoint/attribute_adapter.py11 +12 +13 +14 +15 +16 | |
get(value)
+
+¶convert value retrieved from the the attribute in a table into the adapted type
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
value |
+ + | +value from the database |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +object of the adapted type |
+
datajoint/attribute_adapter.py18 +19 +20 +21 +22 +23 +24 +25 +26 | |
put(obj)
+
+¶convert an object of the adapted type into a value that DataJoint can store in a table attribute
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
obj |
+ + | +an object of the adapted type |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +value to store in the database |
+
datajoint/attribute_adapter.py28 +29 +30 +31 +32 +33 +34 +35 | |
get_adapter(context, adapter_name)
+
+¶Extract the AttributeAdapter object by its name from the context and validate.
+ +datajoint/attribute_adapter.py38 +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 +67 +68 +69 +70 +71 | |
This module defines class dj.AutoPopulate
+ + + +AutoPopulate
+
+
+¶AutoPopulate is a mixin class that adds the method populate() to a Table class.
+Auto-populated tables must inherit from both Table and AutoPopulate,
+must define the property key_source, and must define the callback method make.
datajoint/autopopulate.py44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 | |
key_source()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the query expression that yields primary key values to be passed, sequentially, to the |
+
datajoint/autopopulate.py54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 | |
make(key)
+
+¶Derived classes must implement method make that fetches data from tables
+above them in the dependency hierarchy, restricting by the given key,
+computes secondary attributes, and inserts the new tuples into self.
datajoint/autopopulate.py91 +92 +93 +94 +95 +96 +97 +98 +99 | |
target()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +table to be populated. In the typical case, dj.AutoPopulate is mixed into a dj.Table class by inheritance and the target is self. |
+
datajoint/autopopulate.py101 +102 +103 +104 +105 +106 +107 +108 | |
populate(*restrictions, suppress_errors=False, return_exception_objects=False, reserve_jobs=False, order='original', limit=None, max_calls=None, display_progress=False, processes=1, make_kwargs=None)
+
+¶table.populate() calls table.make(key) for every primary key in
+self.key_source for which there is not already a tuple in table.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
restrictions |
+ + | +a list of restrictions each restrict (table.key_source - target.proj()) |
+ + required + | +
suppress_errors |
+ + | +if True, do not terminate execution. |
+
+ False
+ |
+
return_exception_objects |
+ + | +return error objects instead of just error messages |
+
+ False
+ |
+
reserve_jobs |
+ + | +if True, reserve jobs to populate in asynchronous fashion |
+
+ False
+ |
+
order |
+ + | +"original"|"reverse"|"random" - the order of execution |
+
+ 'original'
+ |
+
limit |
+ + | +if not None, check at most this many keys |
+
+ None
+ |
+
max_calls |
+ + | +if not None, populate at most this many keys |
+
+ None
+ |
+
display_progress |
+ + | +if True, report progress_bar |
+
+ False
+ |
+
processes |
+ + | +number of processes to use. Set to None to use all cores |
+
+ 1
+ |
+
make_kwargs |
+
+ dict, optional
+ |
+ Keyword arguments which do not affect the result of computation to be passed down to each |
+
+ None
+ |
+
datajoint/autopopulate.py151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 | |
progress(*restrictions, display=True)
+
+¶Report the progress of populating the table.
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +(remaining, total) -- numbers of tuples to be populated |
+
datajoint/autopopulate.py317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 | |
(De)serialization methods for basic datatypes and numpy.ndarrays with provisions for mutual +compatibility with Matlab-based serialization implemented by mYm.
+ + + +MatCell
+
+
+¶
+ Bases: np.ndarray
a numpy ndarray representing a Matlab cell array
+ + +datajoint/blob.py73 +74 +75 +76 | |
MatStruct
+
+
+¶
+ Bases: np.recarray
numpy.recarray representing a Matlab struct array
+ + +datajoint/blob.py79 +80 +81 +82 | |
Blob
+
+
+¶datajoint/blob.py85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 | |
squeeze(array, convert_to_scalar=True)
+
+¶Simplify the input array - squeeze out all singleton dimensions. +If convert_to_scalar, then convert zero-dimensional arrays to scalars
+ +datajoint/blob.py101 +102 +103 +104 +105 +106 +107 +108 +109 | |
pack_array(array)
+
+¶Serialize an np.ndarray into bytes. Scalars are encoded with ndim=0.
+ +datajoint/blob.py255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 | |
read_recarray()
+
+¶Serialize an np.ndarray with fields, including recarrays
+ +datajoint/blob.py300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 | |
pack_recarray(array)
+
+¶Serialize a Matlab struct array
+ +datajoint/blob.py317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 | |
read_struct()
+
+¶deserialize matlab stuct
+ +datajoint/blob.py451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 | |
pack_struct(array)
+
+¶Serialize a Matlab struct array
+ +datajoint/blob.py471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 | |
read_cell_array()
+
+¶deserialize MATLAB cell array
+ +datajoint/blob.py487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 | |
read_datetime()
+
+¶deserialize datetime.date, .time, or .datetime
+ +datajoint/blob.py509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 | |
methods for generating SQL WHERE clauses from datajoint restriction conditions
+ + + +PromiscuousOperand
+
+
+¶A container for an operand to ignore join compatibility
+ + +datajoint/condition.py14 +15 +16 +17 +18 +19 +20 | |
AndList
+
+
+¶
+ Bases: list
A list of conditions to by applied to a query expression by logical conjunction: the +conditions are AND-ed. All other collections (lists, sets, other entity sets, etc) are +applied by logical disjunction (OR).
+Example: +expr2 = expr & dj.AndList((cond1, cond2, cond3)) +is equivalent to +expr2 = expr & cond1 & cond2 & cond3
+ + +datajoint/condition.py23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 | |
Not
+
+
+¶invert restriction
+ + +datajoint/condition.py43 +44 +45 +46 +47 | |
assert_join_compatibility(expr1, expr2)
+
+¶Determine if expressions expr1 and expr2 are join-compatible. To be join-compatible, +the matching attributes in the two expressions must be in the primary key of one or the +other expression. +Raises an exception if not compatible.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
expr1 |
+ + | +A QueryExpression object |
+ + required + | +
expr2 |
+ + | +A QueryExpression object |
+ + required + | +
datajoint/condition.py50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 | |
make_condition(query_expression, condition, columns)
+
+¶Translate the input condition into the equivalent SQL condition (a string)
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
query_expression |
+ + | +a dj.QueryExpression object to apply condition |
+ + required + | +
condition |
+ + | +any valid restriction object. |
+ + required + | +
columns |
+ + | +a set passed by reference to collect all column names used in the condition. |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +an SQL condition string or a boolean value. |
+
datajoint/condition.py84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 | |
extract_column_names(sql_expression)
+
+¶extract all presumed column names from an sql expression such as the WHERE clause, +for example.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
sql_expression |
+ + | +a string containing an SQL expression |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +set of extracted column names This may be MySQL-specific for now. |
+
datajoint/condition.py237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 | |
This module contains the Connection class that manages the connection to the database, and
+the conn function that provides access to a persistent connection in datajoint.
translate_query_error(client_error, query)
+
+¶Take client error and original query and return the corresponding DataJoint exception.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
client_error |
+ + | +the exception raised by the client interface |
+ + required + | +
query |
+ + | +sql query with placeholders |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +an instance of the corresponding subclass of datajoint.errors.DataJointError |
+
datajoint/connection.py55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 | |
conn(host=None, user=None, password=None, *, init_fun=None, reset=False, use_tls=None)
+
+¶Returns a persistent connection object to be shared by multiple modules. +If the connection is not yet established or reset=True, a new connection is set up. +If connection information is not provided, it is taken from config which takes the +information from dj_local_conf.json. If the password is not specified in that file +datajoint prompts for the password.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
host |
+ + | +hostname |
+
+ None
+ |
+
user |
+ + | +mysql user |
+
+ None
+ |
+
password |
+ + | +mysql password |
+
+ None
+ |
+
init_fun |
+ + | +initialization function |
+
+ None
+ |
+
reset |
+ + | +whether the connection should be reset or not |
+
+ False
+ |
+
use_tls |
+ + | +TLS encryption option. Valid options are: True (required), False (required no TLS), None (TLS prefered, default), dict (Manually specify values per https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#encrypted-connection-options). |
+
+ None
+ |
+
datajoint/connection.py100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 | |
EmulatedCursor
+
+
+¶acts like a cursor
+ + +datajoint/connection.py135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 | |
Connection
+
+
+¶A dj.Connection object manages a connection to a database server. +It also catalogues modules, schemas, tables, and their dependencies (foreign keys).
+Most of the parameters below should be set in the local configuration file.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
host |
+ + | +host name, may include port number as hostname:port, in which case it overrides the value in port |
+ + required + | +
user |
+ + | +user name |
+ + required + | +
password |
+ + | +password |
+ + required + | +
port |
+ + | +port number |
+
+ None
+ |
+
init_fun |
+ + | +connection initialization function (SQL) |
+
+ None
+ |
+
use_tls |
+ + | +TLS encryption option |
+
+ None
+ |
+
datajoint/connection.py159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 | |
connect()
+
+¶Connect to the database server.
+ +datajoint/connection.py212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 | |
set_query_cache(query_cache=None)
+
+¶When query_cache is not None, the connection switches into the query caching mode, which entails: +1. Only SELECT queries are allowed. +2. The results of queries are cached under the path indicated by dj.config['query_cache'] +3. query_cache is a string that differentiates different cache states.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
query_cache |
+ + | +a string to initialize the hash for query results |
+
+ None
+ |
+
datajoint/connection.py246 +247 +248 +249 +250 +251 +252 +253 +254 +255 | |
purge_query_cache()
+
+¶Purges all query cache.
+ +datajoint/connection.py257 +258 +259 +260 +261 +262 +263 +264 +265 | |
ping()
+
+¶Ping the connection or raises an exception if the connection is closed.
+ +datajoint/connection.py274 +275 +276 | |
is_connected()
+
+
+ property
+
+
+¶Return true if the object is connected to the database server.
+ +datajoint/connection.py278 +279 +280 +281 +282 +283 +284 +285 | |
query(query, args=(), *, as_dict=False, suppress_warnings=True, reconnect=None)
+
+¶Execute the specified query and return the tuple generator (cursor).
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
query |
+ + | +SQL query |
+ + required + | +
args |
+ + | +additional arguments for the client.cursor |
+
+ ()
+ |
+
as_dict |
+ + | +If as_dict is set to True, the returned cursor objects returns query results as dictionary. |
+
+ False
+ |
+
suppress_warnings |
+ + | +If True, suppress all warnings arising from underlying query library |
+
+ True
+ |
+
reconnect |
+ + | +when None, get from config, when True, attempt to reconnect if disconnected |
+
+ None
+ |
+
datajoint/connection.py298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 | |
get_user()
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the user name and host name provided by the client to the server. |
+
datajoint/connection.py362 +363 +364 +365 +366 | |
in_transaction()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +True if there is an open transaction. |
+
datajoint/connection.py369 +370 +371 +372 +373 +374 +375 | |
start_transaction()
+
+¶Starts a transaction error.
+ +datajoint/connection.py377 +378 +379 +380 +381 +382 +383 +384 +385 | |
cancel_transaction()
+
+¶Cancels the current transaction and rolls back all changes made during the transaction.
+ +datajoint/connection.py387 +388 +389 +390 +391 +392 +393 | |
commit_transaction()
+
+¶Commit all changes made during the transaction and close it.
+ +datajoint/connection.py395 +396 +397 +398 +399 +400 +401 +402 | |
transaction()
+
+
+ property
+
+
+¶Context manager for transactions. Opens an transaction and closes it after the with statement. +If an error is caught during the transaction, the commits are automatically rolled back. +All errors are raised again.
+Example:
+++ +++++import datajoint as dj +with dj.conn().transaction as conn: + # transaction is open here
+
datajoint/connection.py405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 | |
This module hosts functions to convert DataJoint table definitions into mysql table definitions, and to +declare the corresponding mysql tables.
+ + + +is_foreign_key(line)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
line |
+ + | +a line from the table definition |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +true if the line appears to be a foreign key definition |
+
datajoint/declare.py153 +154 +155 +156 +157 +158 +159 +160 | |
compile_foreign_key(line, context, attributes, primary_key, attr_sql, foreign_key_sql, index_sql)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
line |
+ + | +a line from a table definition |
+ + required + | +
context |
+ + | +namespace containing referenced objects |
+ + required + | +
attributes |
+ + | +list of attribute names already in the declaration -- to be updated by this function |
+ + required + | +
primary_key |
+ + | +None if the current foreign key is made from the dependent section. Otherwise it is the list of primary key attributes thus far -- to be updated by the function |
+ + required + | +
attr_sql |
+ + | +list of sql statements defining attributes -- to be updated by this function. |
+ + required + | +
foreign_key_sql |
+ + | +list of sql statements specifying foreign key constraints -- to be updated by this function. |
+ + required + | +
index_sql |
+ + | +list of INDEX declaration statements, duplicate or redundant indexes are ok. |
+ + required + | +
datajoint/declare.py163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 | |
declare(full_table_name, definition, context)
+
+¶Parse declaration and generate the SQL CREATE TABLE code
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
full_table_name |
+ + | +full name of the table |
+ + required + | +
definition |
+ + | +DataJoint table definition |
+ + required + | +
context |
+ + | +dictionary of objects that might be referred to in the table |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +SQL CREATE TABLE statement, list of external stores used |
+
datajoint/declare.py366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 | |
alter(definition, old_definition, context)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
definition |
+ + | +new table definition |
+ + required + | +
old_definition |
+ + | +current table definition |
+ + required + | +
context |
+ + | +the context in which to evaluate foreign key definitions |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +string SQL ALTER command, list of new stores used for external storage |
+
datajoint/declare.py478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 | |
substitute_special_type(match, category, foreign_key_sql, context)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
match |
+ + | +dict containing with keys "type" and "comment" -- will be modified in place |
+ + required + | +
category |
+ + | +attribute type category from TYPE_PATTERN |
+ + required + | +
foreign_key_sql |
+ + | +list of foreign key declarations to add to |
+ + required + | +
context |
+ + | +context for looking up user-defined attribute_type adapters |
+ + required + | +
datajoint/declare.py526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 | |
compile_attribute(line, in_key, foreign_key_sql, context)
+
+¶Convert attribute definition from DataJoint format to SQL
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
line |
+ + | +attribution line |
+ + required + | +
in_key |
+ + | +set to True if attribute is in primary key set |
+ + required + | +
foreign_key_sql |
+ + | +the list of foreign key declarations to add to |
+ + required + | +
context |
+ + | +context in which to look up user-defined attribute type adapterss |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +(name, sql, is_external) -- attribute name and sql code for its declaration |
+
datajoint/declare.py567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 | |
unite_master_parts(lst)
+
+¶re-order a list of table names so that part tables immediately follow their master tables without breaking
+the topological order.
+Without this correction, a simple topological sort may insert other descendants between master and parts.
+The input list must be topologically sorted.
+:example:
+unite_master_parts(
+ ['s.a', 's.a__q', 's.b', 's.c', 's.c__q', 's.b__q', 's.d', 's.a__r']) ->
+ ['s.a', 's.a__q', 's.a__r', 's.b', 's.b__q', 's.c', 's.c__q', 's.d']
datajoint/dependencies.py8 + 9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 | |
Dependencies
+
+
+¶
+ Bases: nx.DiGraph
The graph of dependencies (foreign keys) between loaded tables.
+Note: the 'connection' argument should normally be supplied; +Empty use is permitted to facilitate use of networkx algorithms which +internally create objects with the expectation of empty constructors. +See also: https://github.com/datajoint/datajoint-python/pull/443
+ + +datajoint/dependencies.py32 + 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 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 | |
load(force=True)
+
+¶Load dependencies for all loaded schemas. +This method gets called before any operation that requires dependencies: delete, drop, populate, progress.
+ +datajoint/dependencies.py52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 | |
parents(table_name, primary=None)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
table_name |
+ + | +
|
+ + required + | +
primary |
+ + | +if None, then all parents are returned. If True, then only foreign keys composed of primary key attributes are considered. If False, the only foreign keys including at least one non-primary attribute are considered. |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +dict of tables referenced by the foreign keys of table |
+
datajoint/dependencies.py134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 | |
children(table_name, primary=None)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
table_name |
+ + | +
|
+ + required + | +
primary |
+ + | +if None, then all children are returned. If True, then only foreign keys composed of primary key attributes are considered. If False, the only foreign keys including at least one non-primary attribute are considered. |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +dict of tables referencing the table through foreign keys |
+
datajoint/dependencies.py149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 | |
descendants(full_table_name)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
full_table_name |
+ + | +In form |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +all dependent tables sorted in topological order. Self is included. |
+
datajoint/dependencies.py164 +165 +166 +167 +168 +169 +170 +171 +172 +173 | |
ancestors(full_table_name)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
full_table_name |
+ + | +In form |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +all dependent tables sorted in topological order. Self is included. |
+
datajoint/dependencies.py175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 | |
Diagram
+
+
+¶
+ Bases: nx.DiGraph
Entity relationship diagram.
+Usage:
+++++++diag = Diagram(source)
+
source can be a base table object, a base table class, a schema, or a module that has a schema.
+++++++diag.draw()
+
draws the diagram using pyplot
+diag1 + diag2 - combines the two diagrams. +diag + n - expands n levels of successors +diag - n - expands n levels of predecessors +Thus dj.Diagram(schema.Table)+1-1 defines the diagram of immediate ancestors and descendants of schema.Table
+Note that diagram + 1 - 1 may differ from diagram - 1 + 1 and so forth. +Only those tables that are loaded in the connection object are displayed
+ + +datajoint/diagram.py73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 | |
from_sequence(sequence)
+
+
+ classmethod
+
+
+¶The join Diagram for all objects in sequence
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
sequence |
+ + | +a sequence (e.g. list, tuple) |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +Diagram(arg1) + ... + Diagram(argn) |
+
datajoint/diagram.py146 +147 +148 +149 +150 +151 +152 +153 +154 | |
add_parts()
+
+¶Adds to the diagram the part tables of tables already included in the diagram
+ +Returns:
+| Type | +Description | +
|---|---|
| + | ++ |
datajoint/diagram.py156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 | |
topological_sort()
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +list of nodes in topological order |
+
datajoint/diagram.py183 +184 +185 +186 +187 +188 +189 +190 +191 | |
Exception classes for the DataJoint library
+ + + +DataJointError
+
+
+¶
+ Bases: Exception
Base class for errors specific to DataJoint internal operation.
+ + +datajoint/errors.py14 +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 | |
suggest(*args)
+
+¶regenerate the exception with additional arguments
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
args |
+ + | +addition arguments |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +a new exception of the same type with the additional arguments |
+
datajoint/errors.py34 +35 +36 +37 +38 +39 +40 +41 | |
LostConnectionError
+
+
+¶
+ Bases: DataJointError
Loss of server connection
+ + +datajoint/errors.py45 +46 +47 +48 | |
QueryError
+
+
+¶
+ Bases: DataJointError
Errors arising from queries to the database
+ + +datajoint/errors.py51 +52 +53 +54 | |
QuerySyntaxError
+
+
+¶
+ Bases: QueryError
Errors arising from incorrect query syntax
+ + +datajoint/errors.py58 +59 +60 +61 | |
AccessError
+
+
+¶
+ Bases: QueryError
User access error: insufficient privileges.
+ + +datajoint/errors.py64 +65 +66 +67 | |
MissingTableError
+
+
+¶
+ Bases: DataJointError
Query on a table that has not been declared
+ + +datajoint/errors.py70 +71 +72 +73 | |
DuplicateError
+
+
+¶
+ Bases: QueryError
An integrity error caused by a duplicate entry into a unique key
+ + +datajoint/errors.py76 +77 +78 +79 | |
IntegrityError
+
+
+¶
+ Bases: QueryError
An integrity error triggered by foreign key constraints
+ + +datajoint/errors.py82 +83 +84 +85 | |
UnknownAttributeError
+
+
+¶
+ Bases: QueryError
User requests an attribute name not found in query heading
+ + +datajoint/errors.py88 +89 +90 +91 | |
MissingAttributeError
+
+
+¶
+ Bases: QueryError
An error arising when a required attribute value is not provided in INSERT
+ + +datajoint/errors.py94 +95 +96 +97 | |
MissingExternalFile
+
+
+¶
+ Bases: DataJointError
Error raised when an external file managed by DataJoint is no longer accessible
+ + +datajoint/errors.py100 +101 +102 +103 | |
BucketInaccessible
+
+
+¶
+ Bases: DataJointError
Error raised when a S3 bucket is inaccessible
+ + +datajoint/errors.py106 +107 +108 +109 | |
AndList
+
+
+¶
+ Bases: list
A list of conditions to by applied to a query expression by logical conjunction: the +conditions are AND-ed. All other collections (lists, sets, other entity sets, etc) are +applied by logical disjunction (OR).
+Example: +expr2 = expr & dj.AndList((cond1, cond2, cond3)) +is equivalent to +expr2 = expr & cond1 & cond2 & cond3
+ + +datajoint/condition.py23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 | |
QueryExpression
+
+
+¶QueryExpression implements query operators to derive new entity set from its input. +A QueryExpression object generates a SELECT statement in SQL. +QueryExpression operators are restrict, join, proj, aggr, and union.
+A QueryExpression object has a support, a restriction (an AndList), and heading.
+Property heading (type dj.Heading) contains information about the attributes.
+It is loaded from the database and updated by proj.
Property support is the list of table names or other QueryExpressions to be joined.
The restriction is applied first without having access to the attributes generated by the projection. +Then projection is applied by selecting modifying the heading attribute.
+Application of operators does not always lead to the creation of a subquery. +A subquery is generated when: + 1. A restriction is applied on any computed or renamed attributes + 2. A projection is applied remapping remapped attributes + 3. Subclasses: Join, Aggregation, and Union have additional specific rules.
+ + +datajoint/expression.py23 + 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 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 | |
connection()
+
+
+ property
+
+
+¶a dj.Connection object
+ +datajoint/expression.py58 +59 +60 +61 +62 | |
support()
+
+
+ property
+
+
+¶A list of table names or subqueries to from the FROM clause
+ +datajoint/expression.py64 +65 +66 +67 +68 | |
heading()
+
+
+ property
+
+
+¶a dj.Heading object, reflects the effects of the projection operator .proj
+ +datajoint/expression.py70 +71 +72 +73 | |
original_heading()
+
+
+ property
+
+
+¶a dj.Heading object reflecting the attributes before projection
+ +datajoint/expression.py75 +76 +77 +78 | |
restriction()
+
+
+ property
+
+
+¶a AndList object of restrictions applied to input to produce the result
+ +datajoint/expression.py80 +81 +82 +83 +84 +85 | |
restriction_attributes()
+
+
+ property
+
+
+¶the set of attribute names invoked in the WHERE clause
+ +datajoint/expression.py87 +88 +89 +90 +91 +92 | |
make_sql(fields=None)
+
+¶Make the SQL SELECT statement.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
fields |
+ + | +used to explicitly set the select attributes |
+
+ None
+ |
+
datajoint/expression.py121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 | |
make_subquery()
+
+¶create a new SELECT statement where self is the FROM clause
+ +datajoint/expression.py135 +136 +137 +138 +139 +140 +141 | |
restrict(restriction)
+
+¶Produces a new expression with the new restriction applied. +rel.restrict(restriction) is equivalent to rel & restriction. +rel.restrict(Not(restriction)) is equivalent to rel - restriction +The primary key of the result is unaffected. +Successive restrictions are combined as logical AND: r & a & b is equivalent to r & AndList((a, b)) +Any QueryExpression, collection, or sequence other than an AndList are treated as OrLists +(logical disjunction of conditions) +Inverse restriction is accomplished by either using the subtraction operator or the Not class.
+The expressions in each row equivalent:
+rel & True rel +rel & False the empty entity set +rel & 'TRUE' rel +rel & 'FALSE' the empty entity set +rel - cond rel & Not(cond) +rel - 'TRUE' rel & False +rel - 'FALSE' rel +rel & AndList((cond1,cond2)) rel & cond1 & cond2 +rel & AndList() rel +rel & [cond1, cond2] rel & OrList((cond1, cond2)) +rel & [] rel & False +rel & None rel & False +rel & any_empty_entity_set rel & False +rel - AndList((cond1,cond2)) rel & [Not(cond1), Not(cond2)] +rel - [cond1, cond2] rel & Not(cond1) & Not(cond2) +rel - AndList() rel & False +rel - [] rel +rel - None rel +rel - any_empty_entity_set rel
+When arg is another QueryExpression, the restriction rel & arg restricts rel to elements that match at least +one element in arg (hence arg is treated as an OrList). +Conversely, rel - arg restricts rel to elements that do not match any elements in arg. +Two elements match when their common attributes have equal values or when they have no common attributes. +All shared attributes must be in the primary key of either rel or arg or both or an error will be raised.
+QueryExpression.restrict is the only access point that modifies restrictions. All other operators must +ultimately call restrict()
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
restriction |
+ + | +a sequence or an array (treated as OR list), another QueryExpression, an SQL condition string, or an AndList. |
+ + required + | +
datajoint/expression.py143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 | |
join(other, semantic_check=True, left=False)
+
+¶create the joined QueryExpression. +a * b is short for A.join(B) +a @ b is short for A.join(B, semantic_check=False) +Additionally, left=True will retain the rows of self, effectively performing a left join.
+ +datajoint/expression.py270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 | |
proj(*attributes, **named_attributes)
+
+¶Projection operator.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
attributes |
+ + | +attributes to be included in the result. (The primary key is already included). |
+ + required + | +
named_attributes |
+ + | +new attributes computed or renamed from existing attributes. |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +the projected expression. Primary key attributes cannot be excluded but may be renamed. If the attribute list contains an Ellipsis ..., then all secondary attributes are included too Prefixing an attribute name with a dash '-attr' removes the attribute from the list if present. Keyword arguments can be used to rename attributes as in name='attr', duplicate them as in name='(attr)', or self.proj(...) or self.proj(Ellipsis) -- include all attributes (return self) self.proj() -- include only primary key self.proj('attr1', 'attr2') -- include primary key and attributes attr1 and attr2 self.proj(..., '-attr1', '-attr2') -- include all attributes except attr1 and attr2 self.proj(name1='attr1') -- include primary key and 'attr1' renamed as name1 self.proj('attr1', dup='(attr1)') -- include primary key and attribute attr1 twice, with the duplicate 'dup' self.proj(k='abs(attr1)') adds the new attribute k with the value computed as an expression (SQL syntax) from other attributes available before the projection. Each attribute name can only be used once. |
+
datajoint/expression.py324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 | |
aggr(group, *attributes, keep_all_rows=False, **named_attributes)
+
+¶Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
+has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of group.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
group |
+ + | +The query expression to be aggregated. |
+ + required + | +
keep_all_rows |
+ + | +True=keep all the rows from self. False=keep only rows that match entries in group. |
+
+ False
+ |
+
named_attributes |
+ + | +computations of the form new_attribute="sql expression on attributes of group" |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +The derived query expression |
+
datajoint/expression.py482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 | |
head(limit=25, **fetch_kwargs)
+
+¶shortcut to fetch the first few entries from query expression. +Equivalent to fetch(order_by="KEY", limit=25)
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
limit |
+ + | +number of entries |
+
+ 25
+ |
+
fetch_kwargs |
+ + | +kwargs for fetch |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +query result |
+
datajoint/expression.py512 +513 +514 +515 +516 +517 +518 +519 +520 +521 | |
tail(limit=25, **fetch_kwargs)
+
+¶shortcut to fetch the last few entries from query expression. +Equivalent to fetch(order_by="KEY DESC", limit=25)[::-1]
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
limit |
+ + | +number of entries |
+
+ 25
+ |
+
fetch_kwargs |
+ + | +kwargs for fetch |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +query result |
+
datajoint/expression.py523 +524 +525 +526 +527 +528 +529 +530 +531 +532 | |
cursor(offset=0, limit=None, order_by=None, as_dict=False)
+
+¶See expression.fetch() for input description.
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +query cursor |
+
datajoint/expression.py616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 | |
preview(limit=None, width=None)
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +a string of preview of the contents of the query. |
+
datajoint/expression.py645 +646 +647 | |
Not
+
+
+¶invert restriction
+ + +datajoint/condition.py43 +44 +45 +46 +47 | |
Aggregation
+
+
+¶
+ Bases: QueryExpression
Aggregation.create(arg, group, comp1='calc1', ..., compn='calcn') yields an entity set +with primary key from arg. +The computed arguments comp1, ..., compn use aggregation calculations on the attributes of +group or simple projections and calculations on the attributes of arg. +Aggregation is used QueryExpression.aggr and U.aggr. +Aggregation is a private class in DataJoint, not exposed to users.
+ + +datajoint/expression.py654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 | |
Union
+
+
+¶
+ Bases: QueryExpression
Union is the private DataJoint class that implements the union operator.
+ + +datajoint/expression.py728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 | |
from_clause()
+
+¶The union does not use a FROM clause
+ +datajoint/expression.py790 +791 +792 | |
where_clause()
+
+¶The union does not use a WHERE clause
+ +datajoint/expression.py794 +795 +796 | |
U
+
+
+¶dj.U objects are the universal sets representing all possible values of their attributes. +dj.U objects cannot be queried on their own but are useful for forming some queries. +dj.U('attr1', ..., 'attrn') represents the universal set with the primary key attributes attr1 ... attrn. +The universal set is the set of all possible combinations of values of the attributes. +Without any attributes, dj.U() represents the set with one element that has no attributes.
+Restriction:
+dj.U can be used to enumerate unique combinations of values of attributes from other expressions.
+The following expression yields all unique combinations of contrast and brightness found in the stimulus set:
++++++dj.U('contrast', 'brightness') & stimulus
+
Aggregation:
+In aggregation, dj.U is used for summary calculation over an entire set:
+The following expression yields one element with one attribute s containing the total number of elements in
+query expression expr:
++++++dj.U().aggr(expr, n='count(*)')
+
The following expressions both yield one element containing the number n of distinct values of attribute attr in
+query expressio expr.
++++++dj.U().aggr(expr, n='count(distinct attr)') +dj.U().aggr(dj.U('attr').aggr(expr), 'n=count(*)')
+
The following expression yields one element and one attribute s containing the sum of values of attribute attr
+over entire result set of expression expr:
++++++dj.U().aggr(expr, s='sum(attr)')
+
The following expression yields the set of all unique combinations of attributes attr1, attr2 and the number of
+their occurrences in the result set of query expression expr.
++++++dj.U(attr1,attr2).aggr(expr, n='count(*)')
+
Joins:
+If expression expr has attributes 'attr1' and 'attr2', then expr * dj.U('attr1','attr2') yields the same result
+as expr but attr1 and attr2 are promoted to the the primary key. This is useful for producing a join on
+non-primary key attributes.
+For example, if attr is in both expr1 and expr2 but not in their primary keys, then expr1 * expr2 will throw
+an error because in most cases, it does not make sense to join on non-primary key attributes and users must first
+rename attr in one of the operands. The expression dj.U('attr') * rel1 * rel2 overrides this constraint.
datajoint/expression.py812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 | |
join(other, left=False)
+
+¶Joining U with a query expression has the effect of promoting the attributes of U to +the primary key of the other query expression.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
other |
+ + | +the other query expression to join with. |
+ + required + | +
left |
+ + | +ignored. dj.U always acts as if left=False |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +a copy of the other query expression with the primary key extended. |
+
datajoint/expression.py881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 | |
aggr(group, **named_attributes)
+
+¶Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
+has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of group.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
group |
+ + | +The query expression to be aggregated. |
+ + required + | +
named_attributes |
+ + | +computations of the form new_attribute="sql expression on attributes of group" |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +The derived query expression |
+
datajoint/expression.py912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 | |
subfold(name, folds)
+
+¶subfolding for external storage: e.g. subfold('aBCdefg', (2, 3)) --> ['ab','cde']
+ +datajoint/external.py23 +24 +25 +26 +27 +28 +29 +30 +31 | |
ExternalTable
+
+
+¶
+ Bases: Table
The table tracking externally stored objects. +Declare as ExternalTable(connection, database)
+ + +datajoint/external.py34 + 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 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 | |
exists(external_filepath)
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +True if the external file is accessible |
+
datajoint/external.py156 +157 +158 +159 +160 +161 +162 +163 +164 | |
put(blob)
+
+¶put a binary string (blob) in external store
+ +datajoint/external.py168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 | |
get(uuid)
+
+¶get an object from external store.
+ +datajoint/external.py184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 | |
download_attachment(uuid, attachment_name, download_path)
+
+¶save attachment from memory buffer into the save_path
+ +datajoint/external.py245 +246 +247 +248 | |
upload_filepath(local_filepath)
+
+¶Raise exception if an external entry already exists with a different contents checksum. +Otherwise, copy (with overwrite) file to remote and +If an external entry exists with the same checksum, then no copying should occur
+ +datajoint/external.py252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 | |
download_filepath(filepath_hash)
+
+¶sync a file from external store to the local stage
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
filepath_hash |
+ + | +The hash (UUID) of the relative_path |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +hash (UUID) of the contents of the downloaded file or Nones |
+
datajoint/external.py299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 | |
references()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +generator of referencing table names and their referencing columns |
+
datajoint/external.py347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 | |
fetch_external_paths(**fetch_kwargs)
+
+¶generate complete external filepaths from the query. +Each element is a tuple: (uuid, path)
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
fetch_kwargs |
+ + | +keyword arguments to pass to fetch |
+ + required + | +
datajoint/external.py366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 | |
unused()
+
+¶query expression for unused hashes
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +self restricted to elements that are not in use by any tables in the schema |
+
datajoint/external.py388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 | |
used()
+
+¶query expression for used hashes
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +self restricted to elements that in use by tables in the schema |
+
datajoint/external.py401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 | |
delete(*, delete_external_files=None, limit=None, display_progress=True, errors_as_string=True)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
delete_external_files |
+ + | +True or False. If False, only the tracking info is removed from the external store table but the external files remain intact. If True, then the external files themselves are deleted too. |
+
+ None
+ |
+
errors_as_string |
+ + | +If True any errors returned when deleting from external files will be strings |
+
+ True
+ |
+
limit |
+ + | +(integer) limit the number of items to delete |
+
+ None
+ |
+
display_progress |
+ + | +if True, display progress as files are cleaned up |
+
+ True
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +if deleting external files, returns errors |
+
datajoint/external.py414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 | |
ExternalMapping
+
+
+¶
+ Bases: Mapping
The external manager contains all the tables for all external stores for a given schema +:Example: + e = ExternalMapping(schema) + external_table = e[store]
+ + +datajoint/external.py468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 | |
key
+
+
+¶object that allows requesting the primary key as an argument in expression.fetch() +The string "KEY" can be used instead of the class key
+ + +datajoint/fetch.py18 +19 +20 +21 +22 +23 +24 | |
to_dicts(recarray)
+
+¶convert record array to a dictionaries
+ +datajoint/fetch.py31 +32 +33 +34 | |
Fetch
+
+
+¶A fetch object that handles retrieving elements from the table expression.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
expression |
+ + | +the QueryExpression object to fetch from. |
+ + required + | +
datajoint/fetch.py135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 | |
Fetch1
+
+
+¶Fetch object for fetching the result of a query yielding one row.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
expression |
+ + | +a query expression to fetch from. |
+ + required + | +
datajoint/fetch.py295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 | |
key_hash(mapping)
+
+¶32-byte hash of the mapping's key values sorted by the key name. +This is often used to convert a long primary key value into a shorter hash. +For example, the JobTable in datajoint.jobs uses this function to hash the primary key of autopopulated tables.
+ +datajoint/hash.py7 + 8 + 9 +10 +11 +12 +13 +14 +15 +16 | |
uuid_from_stream(stream, *, init_string='')
+
+¶:stream: stream object or open file handle +:init_string: string to initialize the checksum
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +16-byte digest of stream data |
+
datajoint/hash.py19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 | |
Attribute
+
+
+¶
+ Bases: namedtuple(_Attribute, default_attribute_properties)
Properties of a table column (attribute)
+ + +datajoint/heading.py45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 | |
todict()
+
+¶Convert namedtuple to dict.
+ +datajoint/heading.py50 +51 +52 | |
sql_type()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +datatype (as string) in database. In most cases, it is the same as self.type |
+
datajoint/heading.py54 +55 +56 +57 | |
sql_comment()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +full comment for the SQL declaration. Includes custom type specification |
+
datajoint/heading.py59 +60 +61 +62 | |
sql()
+
+
+ property
+
+
+¶Convert primary key attribute tuple into its SQL CREATE TABLE clause. +Default values are not reflected. +This is used for declaring foreign keys in referencing tables
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +SQL code for attribute declaration |
+
datajoint/heading.py64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 | |
Heading
+
+
+¶Local class for table headings. +Heading contains the property attributes, which is an dict in which the keys are +the attribute names and the values are Attributes.
+ + +datajoint/heading.py85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 | |
as_dtype()
+
+
+ property
+
+
+¶represent the heading as a numpy dtype
+ +datajoint/heading.py181 +182 +183 +184 +185 +186 +187 +188 | |
as_sql(fields, include_aliases=True)
+
+¶represent heading as the SQL SELECT clause.
+ +datajoint/heading.py190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 | |
select(select_list, rename_map=None, compute_map=None)
+
+¶derive a new heading by selecting, renaming, or computing attributes. +In relational algebra these operators are known as project, rename, and extend.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
select_list |
+ + | +the full list of existing attributes to include |
+ + required + | +
rename_map |
+ + | +dictionary of renamed attributes: keys=new names, values=old names |
+
+ None
+ |
+
compute_map |
+ + | +a direction of computed attributes This low-level method performs no error checking. |
+
+ None
+ |
+
datajoint/heading.py435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 | |
join(other)
+
+¶Join two headings into a new one. +It assumes that self and other are headings that share no common dependent attributes.
+ +datajoint/heading.py468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 | |
set_primary_key(primary_key)
+
+¶Create a new heading with the specified primary key. +This low-level method performs no error checking.
+ +datajoint/heading.py492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 | |
make_subquery_heading()
+
+¶Create a new heading with removed attribute sql_expressions. +Used by subqueries, which resolve the sql_expressions.
+ +datajoint/heading.py511 +512 +513 +514 +515 +516 +517 +518 +519 | |
JobTable
+
+
+¶
+ Bases: Table
A base table with no definition. Allows reserving jobs
+ + +datajoint/jobs.py13 + 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 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 | |
delete()
+
+¶bypass interactive prompts and dependencies
+ +datajoint/jobs.py56 +57 +58 | |
drop()
+
+¶bypass interactive prompts and dependencies
+ +datajoint/jobs.py60 +61 +62 | |
reserve(table_name, key)
+
+¶Reserve a job for computation. When a job is reserved, the job table contains an entry for the +job key, identified by its hash. When jobs are completed, the entry is removed.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
table_name |
+ + | +
|
+ + required + | +
key |
+ + | +the dict of the job's primary key |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +True if reserved job successfully. False = the jobs is already taken |
+
datajoint/jobs.py64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 | |
complete(table_name, key)
+
+¶Log a completed job. When a job is completed, its reservation entry is deleted.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
table_name |
+ + | +
|
+ + required + | +
key |
+ + | +the dict of the job's primary key |
+ + required + | +
datajoint/jobs.py90 +91 +92 +93 +94 +95 +96 +97 +98 | |
error(table_name, key, error_message, error_stack=None)
+
+¶Log an error message. The job reservation is replaced with an error entry. +if an error occurs, leave an entry describing the problem
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
table_name |
+ + | +
|
+ + required + | +
key |
+ + | +the dict of the job's primary key |
+ + required + | +
error_message |
+ + | +string error message |
+ + required + | +
error_stack |
+ + | +stack trace |
+
+ None
+ |
+
datajoint/jobs.py100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 | |
migrate_dj011_external_blob_storage_to_dj012(migration_schema, store)
+
+¶Utility function to migrate external blob data from 0.11 to 0.12.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
migration_schema |
+ + | +string of target schema to be migrated |
+ + required + | +
store |
+ + | +string of target dj.config['store'] to be migrated |
+ + required + | +
datajoint/migrate.py7 + 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 | |
AWS S3 operations
+ + + +Folder
+
+
+¶A Folder instance manipulates a flat folder of objects within an S3-compatible object store
+ + +datajoint/s3.py15 + 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 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 | |
fget(name, local_filepath)
+
+¶get file from object name to local filepath
+ +datajoint/s3.py78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 | |
ordered_dir(class_)
+
+¶List (most) attributes of the class including inherited ones, similar to dir build-in function,
+but respects order of attribute declaration as much as possible.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
class_ |
+ + | +class to list members for |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +a list of attributes declared in class_ and its superclasses |
+
datajoint/schemas.py22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 | |
Schema
+
+
+¶A schema object is a decorator for UserTable classes that binds them to their database.
+It also specifies the namespace context in which other UserTable classes are defined.
datajoint/schemas.py36 + 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 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 | |
activate(schema_name=None, *, connection=None, create_schema=None, create_tables=None, add_objects=None)
+
+¶Associate database schema schema_name. If the schema does not exist, attempt to
+create it on the server.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
schema_name |
+ + | +the database schema to associate. schema_name=None is used to assert that the schema has already been activated. |
+
+ None
+ |
+
connection |
+ + | +Connection object. Defaults to datajoint.conn(). |
+
+ None
+ |
+
create_schema |
+ + | +If False, do not create the schema and raise an error if missing. |
+
+ None
+ |
+
create_tables |
+ + | +If False, do not create tables and raise errors when attempting to access missing tables. |
+
+ None
+ |
+
add_objects |
+ + | +a mapping with additional objects to make available to the context in which table classes are declared. |
+
+ None
+ |
+
datajoint/schemas.py83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 | |
size_on_disk()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +size of the entire schema in bytes |
+
datajoint/schemas.py266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 | |
spawn_missing_classes(context=None)
+
+¶Creates the appropriate python user table classes from tables in the schema and places them +in the context.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
context |
+ + | +alternative context to place the missing classes into, e.g. locals() |
+
+ None
+ |
+
datajoint/schemas.py283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 | |
drop(force=False)
+
+¶Drop the associated schema if it exists
+ +datajoint/schemas.py343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 | |
exists()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +true if the associated schema exists on the server |
+
datajoint/schemas.py377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 | |
jobs()
+
+
+ property
+
+
+¶schema.jobs provides a view of the job reservation table for the schema
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +jobs table |
+
datajoint/schemas.py392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 | |
save(python_filename=None)
+
+¶Generate the code for a module that recreates the schema. +This method is in preparation for a future release and is not officially supported.
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +a string containing the body of a complete Python module defining this schema. |
+
datajoint/schemas.py409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 | |
list_tables()
+
+¶Return a list of all tables in the schema except tables with ~ in first character such +as ~logs and ~job
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +A list of table names from the database schema. |
+
datajoint/schemas.py476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 | |
VirtualModule
+
+
+¶
+ Bases: types.ModuleType
A virtual module imitates a Python module representing a DataJoint schema from table definitions in the database. +It declares the schema objects and a class for each table.
+ + +datajoint/schemas.py493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 | |
list_schemas(connection=None)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
connection |
+ + | +a dj.Connection object |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of all accessible schemas on the server |
+
datajoint/schemas.py534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 | |
Settings for DataJoint.
+ + + +Config
+
+
+¶
+ Bases: collections.abc.MutableMapping
datajoint/settings.py64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 | |
save(filename, verbose=False)
+
+¶Saves the settings in JSON format to the given file path.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
filename |
+ + | +filename of the local JSON settings file. |
+ + required + | +
verbose |
+ + | +report having saved the settings file |
+
+ False
+ |
+
datajoint/settings.py98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 | |
load(filename)
+
+¶Updates the setting from config file in JSON format.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
filename |
+ + | +filename of the local JSON settings file. If None, the local config file is used. |
+ + required + | +
datajoint/settings.py110 +111 +112 +113 +114 +115 +116 +117 +118 +119 | |
save_local(verbose=False)
+
+¶saves the settings in the local config file
+ +datajoint/settings.py121 +122 +123 +124 +125 | |
save_global(verbose=False)
+
+¶saves the settings in the global config file
+ +datajoint/settings.py127 +128 +129 +130 +131 | |
get_store_spec(store)
+
+¶find configuration of external stores for blobs and attachments
+ +datajoint/settings.py133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 | |
Table
+
+
+¶
+ Bases: QueryExpression
Table is an abstract class that represents a table in the schema. +It implements insert and delete methods and inherits query functionality. +To make it a concrete class, override the abstract properties specifying the connection, +table name, database, and definition.
+ + +datajoint/table.py56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 +847 +848 +849 +850 +851 +852 +853 +854 +855 +856 +857 +858 +859 +860 +861 +862 +863 +864 +865 +866 +867 +868 +869 +870 +871 +872 +873 +874 +875 +876 +877 +878 +879 +880 +881 +882 +883 +884 +885 +886 +887 +888 +889 +890 +891 +892 +893 +894 +895 +896 +897 +898 +899 +900 +901 +902 +903 +904 +905 +906 +907 +908 +909 +910 +911 +912 +913 +914 +915 +916 +917 +918 +919 +920 +921 +922 +923 +924 +925 +926 +927 +928 +929 +930 +931 +932 +933 +934 +935 +936 +937 +938 +939 +940 +941 +942 +943 +944 +945 +946 +947 +948 | |
declare(context=None)
+
+¶Declare the table in the schema based on self.definition.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
context |
+ + | +the context for foreign key resolution. If None, foreign keys are not allowed. |
+
+ None
+ |
+
datajoint/table.py82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 | |
alter(prompt=True, context=None)
+
+¶Alter the table definition from self.definition
+ +datajoint/table.py107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 | |
from_clause()
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the FROM clause of SQL SELECT statements. |
+
datajoint/table.py147 +148 +149 +150 +151 | |
get_select_fields(select_fields=None)
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the selected attributes from the SQL SELECT statement. |
+
datajoint/table.py153 +154 +155 +156 +157 +158 +159 | |
parents(primary=None, as_objects=False, foreign_key_info=False)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
primary |
+ + | +if None, then all parents are returned. If True, then only foreign keys composed of primary key attributes are considered. If False, return foreign keys including at least one secondary attribute. |
+
+ None
+ |
+
as_objects |
+ + | +if False, return table names. If True, return table objects. |
+
+ False
+ |
+
foreign_key_info |
+ + | +if True, each element in result also includes foreign key info. |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of parents as table names or table objects with (optional) foreign key information. |
+
datajoint/table.py161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 | |
children(primary=None, as_objects=False, foreign_key_info=False)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
primary |
+ + | +if None, then all children are returned. If True, then only foreign keys composed of primary key attributes are considered. If False, return foreign keys including at least one secondary attribute. |
+
+ None
+ |
+
as_objects |
+ + | +if False, return table names. If True, return table objects. |
+
+ False
+ |
+
foreign_key_info |
+ + | +if True, each element in result also includes foreign key info. |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of children as table names or table objects with (optional) foreign key information. |
+
datajoint/table.py183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 | |
descendants(as_objects=False)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
as_objects |
+ + | +False - a list of table names; True - a list of table objects. |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of tables descendants in topological order. |
+
datajoint/table.py205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 | |
ancestors(as_objects=False)
+
+¶Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
as_objects |
+ + | +False - a list of table names; True - a list of table objects. |
+
+ False
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +list of tables ancestors in topological order. |
+
datajoint/table.py217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 | |
parts(as_objects=False)
+
+¶return part tables either as entries in a dict with foreign key informaiton or a list of objects
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
as_objects |
+ + | +if False (default), the output is a dict describing the foreign keys. If True, return table objects. |
+
+ False
+ |
+
datajoint/table.py229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 | |
is_declared()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +True is the table is declared in the schema. |
+
datajoint/table.py242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 | |
full_table_name()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +full table name in the schema |
+
datajoint/table.py256 +257 +258 +259 +260 +261 | |
update1(row)
+
+¶update1 updates one existing entry in the table.
+Caution: In DataJoint the primary modes for data manipulation is to insert and
+delete entire records since referential integrity works on the level of records,
+not fields. Therefore, updates are reserved for corrective operations outside of main
+workflow. Use UPDATE methods sparingly with full awareness of potential violations of
+assumptions.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
row |
+ + | +a |
+ + required + | +
datajoint/table.py277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 | |
insert1(row, **kwargs)
+
+¶Insert one data record into the table. For kwargs, see insert().
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
row |
+ + | +a numpy record, a dict-like object, or an ordered sequence to be inserted as one row. |
+ + required + | +
datajoint/table.py328 +329 +330 +331 +332 +333 +334 +335 | |
insert(rows, replace=False, skip_duplicates=False, ignore_extra_fields=False, allow_direct_insert=None)
+
+¶Insert a collection of rows.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
rows |
+ + | +An iterable where an element is a numpy record, a dict-like object, a pandas.DataFrame, a sequence, or a query expression with the same heading as self. |
+ + required + | +
replace |
+ + | +If True, replaces the existing tuple. |
+
+ False
+ |
+
skip_duplicates |
+ + | +If True, silently skip duplicate inserts. |
+
+ False
+ |
+
ignore_extra_fields |
+ + | +If False, fields that are not in the heading raise error. |
+
+ False
+ |
+
allow_direct_insert |
+ + | +applies only in auto-populated tables. If False (default), insert are allowed only from inside the make callback. Example: >>> Table.insert([ >>> dict(subject_id=7, species="mouse", date_of_birth="2014-09-01"), >>> dict(subject_id=8, species="mouse", date_of_birth="2014-09-02")]) |
+
+ None
+ |
+
datajoint/table.py337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 | |
delete_quick(get_count=False)
+
+¶Deletes the table without cascading and without user prompt. +If this table has populated dependent tables, this will fail.
+ +datajoint/table.py448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 | |
delete(transaction=True, safemode=None, force_parts=False)
+
+¶Deletes the contents of the table and its dependent tables, recursively.
+Args:
+ transaction: If True, use of the entire delete becomes an atomic transaction.
+ This is the default and recommended behavior. Set to False if this delete is
+ nested within another transaction.
+ safemode: If True, prohibit nested transactions and prompt to confirm. Default
+ is dj.config['safemode'].
+ force_parts: Delete from parts even when not deleting from their masters.
Returns: + Number of deleted rows (excluding those from dependent tables).
+Raises: + DataJointError: Delete exceeds maximum number of delete attempts. + DataJointError: When deleting within an existing transaction. + DataJointError: Deleting a part table before its master.
+ +datajoint/table.py463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 | |
drop_quick()
+
+¶Drops the table without cascading to dependent tables and without user prompt.
+ +datajoint/table.py614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 | |
drop()
+
+¶Drop the table and all tables that reference it, recursively. +User is prompted for confirmation if config['safemode'] is set to True.
+ +datajoint/table.py628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 | |
size_on_disk()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +size of data and indices in bytes on the storage device |
+
datajoint/table.py664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 | |
describe(context=None, printout=True)
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the definition string for the query using DataJoint DDL. |
+
datajoint/table.py682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 | |
lookup_class_name(name, context, depth=3)
+
+¶given a table name in the form schema_name.table_name, find its class in the context.
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
name |
+ + | +
|
+ + required + | +
context |
+ + | +dictionary representing the namespace |
+ + required + | +
depth |
+ + | +search depth into imported modules, helps avoid infinite recursion. |
+
+ 3
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +class name found in the context or None if not found |
+
datajoint/table.py951 + 952 + 953 + 954 + 955 + 956 + 957 + 958 + 959 + 960 + 961 + 962 + 963 + 964 + 965 + 966 + 967 + 968 + 969 + 970 + 971 + 972 + 973 + 974 + 975 + 976 + 977 + 978 + 979 + 980 + 981 + 982 + 983 + 984 + 985 + 986 + 987 + 988 + 989 + 990 + 991 + 992 + 993 + 994 + 995 + 996 + 997 + 998 + 999 +1000 +1001 +1002 | |
FreeTable
+
+
+¶
+ Bases: Table
A base table without a dedicated class. Each instance is associated with a table +specified by full_table_name.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
conn |
+ + | +a dj.Connection object |
+ + required + | +
full_table_name |
+ + | +in format |
+ + required + | +
datajoint/table.py1005 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +1030 +1031 +1032 +1033 | |
Log
+
+
+¶
+ Bases: Table
The log table for each schema. +Instances are callable. Calls log the time and identifying information along with the event.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
skip_logging |
+ + | +if True, then log entry is skipped by default. See call |
+
+ False
+ |
+
datajoint/table.py1036 +1037 +1038 +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 +1071 +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +1080 +1081 +1082 +1083 +1084 +1085 +1086 +1087 +1088 +1089 +1090 +1091 +1092 +1093 +1094 +1095 +1096 +1097 +1098 +1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 | |
delete()
+
+¶bypass interactive prompts and cascading dependencies
+ +Returns:
+| Type | +Description | +
|---|---|
| + | +number of deleted items |
+
datajoint/table.py1102 +1103 +1104 +1105 +1106 +1107 +1108 | |
drop()
+
+¶bypass interactive prompts and cascading dependencies
+ +datajoint/table.py1110 +1111 +1112 | |
Hosts the table tiers, user tables should be derived from.
+ + + +TableMeta
+
+
+¶
+ Bases: type
TableMeta subclasses allow applying some instance methods and properties directly +at class level. For example, this allows Table.fetch() instead of Table().fetch().
+ + +datajoint/user_tables.py45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 | |
UserTable
+
+
+¶
+ Bases: Table
A subclass of UserTable is a dedicated class interfacing a base table. +UserTable is initialized by the decorator generated by schema().
+ + +datajoint/user_tables.py84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 | |
definition()
+
+
+ property
+
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +a string containing the table definition using the DataJoint DDL. |
+
datajoint/user_tables.py99 +100 +101 +102 +103 +104 +105 +106 | |
table_name()
+
+¶Returns:
+| Type | +Description | +
|---|---|
| + | +the table name of the table formatted for mysql. |
+
datajoint/user_tables.py112 +113 +114 +115 +116 +117 +118 +119 | |
Manual
+
+
+¶
+ Bases: UserTable
Inherit from this class if the table's values are entered manually.
+ + +datajoint/user_tables.py133 +134 +135 +136 +137 +138 +139 | |
Lookup
+
+
+¶
+ Bases: UserTable
Inherit from this class if the table's values are for lookup. This is +currently equivalent to defining the table as Manual and serves semantic +purposes only.
+ + +datajoint/user_tables.py142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 | |
Imported
+
+
+¶
+ Bases: UserTable, AutoPopulate
Inherit from this class if the table's values are imported from external data sources.
+The inherited class must at least provide the function _make_tuples.
datajoint/user_tables.py155 +156 +157 +158 +159 +160 +161 +162 | |
Computed
+
+
+¶
+ Bases: UserTable, AutoPopulate
Inherit from this class if the table's values are computed from other tables in the schema.
+The inherited class must at least provide the function _make_tuples.
datajoint/user_tables.py165 +166 +167 +168 +169 +170 +171 +172 | |
Part
+
+
+¶
+ Bases: UserTable
Inherit from this class if the table's values are details of an entry in another table +and if this table is populated by the other table. For example, the entries inheriting from +dj.Part could be single entries of a matrix, while the parent table refers to the entire matrix. +Part tables are implemented as classes inside classes.
+ + +datajoint/user_tables.py175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 | |
delete(force=False)
+
+¶unless force is True, prohibits direct deletes from parts.
+ +datajoint/user_tables.py220 +221 +222 +223 +224 +225 +226 +227 +228 +229 | |
drop(force=False)
+
+¶unless force is True, prohibits direct deletes from parts.
+ +datajoint/user_tables.py231 +232 +233 +234 +235 +236 +237 +238 +239 +240 | |
General-purpose utilities
+ + + +user_choice(prompt, choices=('yes', 'no'), default=None)
+
+¶Prompts the user for confirmation. The default value, if any, is capitalized.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
prompt |
+ + | +Information to display to the user. |
+ + required + | +
choices |
+ + | +an iterable of possible choices. |
+
+ ('yes', 'no')
+ |
+
default |
+ + | +default choice |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
| + | +the user's choice |
+
datajoint/utils.py17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 | |
get_master(full_table_name)
+
+¶If the table name is that of a part table, then return what the master table name would be.
+This follows DataJoint's table naming convention where a master and a part must be in the
+same schema and the part table is prefixed with the master table name + __.
Example:
+ ephys.session -- master
+ ephys.session__recording -- part
Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
full_table_name |
+
+ str
+ |
+ Full table name including part. |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ str
+ |
+ Supposed master full table name or empty string if not a part table name. |
+
datajoint/utils.py37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 | |
to_camel_case(s)
+
+¶Convert names with under score (_) separation into camel case names.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
s |
+ + | +string in under_score notation |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +string in CamelCase notation Example: >>> to_camel_case("table_name") # returns "TableName" |
+
datajoint/utils.py56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 | |
from_camel_case(s)
+
+¶Convert names in camel case into underscore (_) separated names
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
s |
+ + | +string in CamelCase notation |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
| + | +string in under_score notation Example: >>> from_camel_case("TableName") # yields "table_name" |
+
datajoint/utils.py72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 | |
safe_write(filepath, blob)
+
+¶A two-step write.
+ +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
filename |
+ + | +full path |
+ + required + | +
blob |
+ + | +binary data |
+ + required + | +
datajoint/utils.py92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 | |
safe_copy(src, dest, overwrite=False)
+
+¶Copy the contents of src file into dest file as a two-step process. Skip if dest exists already
+ +datajoint/utils.py107 +108 +109 +110 +111 +112 +113 +114 +115 +116 | |
parse_sql(filepath)
+
+¶yield SQL statements from an SQL file
+ +datajoint/utils.py119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 | |
\n {translation(\"search.result.term.missing\")}: {...missing}\n
\n }\n