12.8.4. crate_anon.testing.models
crate_anon/testing/models.py
Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CRATE.
CRATE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CRATE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CRATE. If not, see <https://www.gnu.org/licenses/>.
Factory Boy SQL Alchemy test models.
- class crate_anon.testing.models.BlobDoc(patient, filename, blob_datetime)[source]
SQLAlchemy ORM class for fictional binary documents.
- class crate_anon.testing.models.FilenameDoc(**kwargs)[source]
SQLAlchemy ORM class for a table containing the filenames of binary documents.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class crate_anon.testing.models.Note(**kwargs)[source]
SQLAlchemy ORM class for fictional notes.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class crate_anon.testing.models.Patient(**kwargs)[source]
SQLAlchemy ORM class for fictional patients.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- crate_anon.testing.models.compile_blob_mysql(type_: TypeEngine, compiler: SQLCompiler, **kw) str[source]
Provides a custom type for the SQLAlchemy
LargeBinarytype under MySQL, by usingLONGBLOB(which overrides the default ofBLOB).MySQL: https://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html
TINYBLOB: up to 2^8 bytes BLOB: up to 2^16 bytes = 64 KiB MEDIUMBLOB: up to 2^24 bytes = 16 MiB <-- minimum for docs LONGBLOB: up to 2^32 bytes = 4 GiB VARBINARY: up to 65535 = 64 KiB
SQL Server: https://msdn.microsoft.com/en-us/library/ms188362.aspx
BINARY: up to 8000 bytes = 8 KB VARBINARY(MAX): up to 2^31 - 1 bytes = 2 GiB <-- minimum for docs IMAGE: deprecated; up to 2^31 - 1 bytes = 2 GiB https://msdn.microsoft.com/en-us/library/ms187993.aspxSQL Alchemy:
_Binary: base class LargeBinary: translates to BLOB in MySQL VARBINARY, as an SQL base data type dialects.mysql.base.LONGBLOB dialects.mssql.base.VARBINARY
Therefore, we can take the LargeBinary type and modify it.