1
- django-spanner
2
- ==============
1
+ Cloud Spanner support for Django
2
+ ================================
3
3
4
- ORM plugin for using Cloud Spanner as a database for Django.
4
+ ORM plugin for using Cloud Spanner as a `database backend
5
+ <https://docs.djangoproject.com/en/2.2/ref/databases/#using-a-3rd-party-database-backend> `__
6
+ for Django.
5
7
6
- 🚨THIS CODE IS STILL UNDER DEVELOPMENT🚨
7
- ========================================
8
8
9
- Table of contents
10
- -----------------
11
-
12
- - `Installing it <#installing-it >`__
13
- - `Using it <#using-it >`__
14
-
15
- - `Format <#format >`__
16
- - `Example <#example >`__
9
+ Installation
10
+ ------------
17
11
18
- - `Functional tests <#functional-tests >`__
19
- - `Django integration tests <#django-integration-tests >`__
12
+ To use this library you'll need a Google Cloud Platform project with the Cloud
13
+ Spanner API enabled. See the `Cloud Spanner Python client docs
14
+ <https://github.com/googleapis/python-spanner/#quick-start> `__ for details.
20
15
21
- - `django\_ test\_ suite.sh <#django_test_suitesh >`__
16
+ Use the version of ``python-spanner-django `` that corresponds to your version
17
+ of Django. For example, ``python-spanner-django `` 2.2.x works with Django
18
+ 2.2.y. (This is the only supported version at this time.)
22
19
23
- - ` Environment variables < #environment-variables >`__
24
- - ` Example run < #example-run >`__
20
+ The minor release number of Django doesn't correspond to the minor release
21
+ number of `` python-spanner-django `` Use the latest minor release of each.
25
22
26
- - ` Parallelization script < #parallelization-script >`__
23
+ To install from PyPI:
27
24
28
- - `Environment variables <#environment-variables >`__
29
- - `Example run <#example-run >`__
25
+ .. code :: shell
30
26
31
- - `Limitations <#limitations >`__
32
- - `How it works <#how-it-works >`__
27
+ pip3 install django-google-spanner
33
28
34
- - `Overall design <#overall-design >`__
35
- - `Internals <#internals >`__
36
29
37
- Installing it
38
- -------------
30
+ To install from source:
39
31
40
- Use the version of django-spanner that corresponds to your version of
41
- Django. For example, django-spanner 2.2.x works with Django 2.2.y. (This
42
- is the only supported version at this time.)
32
+ .. code :: shell
43
33
44
- The minor release number of Django doesn't correspond to the minor
45
- release number of django-spanner. Use the latest minor release of each.
34
+ git clone [email protected] :googleapis/python-spanner-django.git
35
+ cd python-spanner-django
36
+ pip3 install -e .
46
37
47
- .. code :: shell
48
38
49
- pip3 install --user .
39
+ Use
40
+ ---
50
41
51
- Using it
52
- --------
42
+ After ` installing it < #Installation >`__, you'll need to edit your Django
43
+ `` settings.py `` file:
53
44
54
- After ` installing it < #installing-it >`__, you'll need to edit your
55
- Django `` settings.py `` file:
45
+ - Add `` django_spanner `` as the very first entry in the `` INSTALLED_APPS ``
46
+ setting
56
47
57
- - Add ``django_spanner `` as the very first entry in the
58
- ``INSTALLED_APPS `` setting
59
48
60
49
.. code :: python
61
50
@@ -107,18 +96,18 @@ Limitations
107
96
Transaction management isn't supported
108
97
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109
98
110
- django -spanner always works in Django's default transaction behavior,
111
- ``autocommit `` mode. Transactions cannot be controlled manually with
99
+ `` python -spanner-django `` always works in Django's default transaction
100
+ behavior, ``autocommit `` mode. Transactions cannot be controlled manually with
112
101
calls like ``django.db.transaction.atomic() ``.
113
102
114
103
``AutoField `` generates random IDs
115
104
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116
105
117
106
Spanner doesn't have support for auto-generating primary key values.
118
- Therefore, django -spanner monkey-patches ``AutoField `` to generate a
119
- random UUID4. It generates a default using ``Field ``'s ``default ``
120
- option which means ``AutoField ``\ s will have a value when a model
121
- instance is created. For example:
107
+ Therefore, `` python -spanner-django `` monkey-patches ``AutoField `` to generate a
108
+ random UUID4. It generates a default using ``Field ``'s ``default `` option which
109
+ means ``AutoField ``\ s will have a value when a model instance is created. For
110
+ example:
122
111
123
112
::
124
113
@@ -136,16 +125,18 @@ were created.
136
125
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137
126
138
127
Spanner doesn't support ``ON DELETE CASCADE `` when creating foreign-key
139
- constraints so django-spanner `doesn't support foreign key
140
- constraints <https://github.com/googleapis/python-spanner-django/issues/313> `__.
128
+ constraints so ``python-spanner-django `` `doesn't support foreign key
129
+ constraints
130
+ <https://github.com/googleapis/python-spanner-django/issues/313> `__.
141
131
142
132
Check constraints aren't supported
143
133
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144
134
145
135
Spanner doesn't support ``CHECK `` constraints so one isn't created for
146
- ```PositiveIntegerField `` <https://docs.djangoproject.com/en/stable/ref/models/fields/#positiveintegerfield>`__
147
- and
148
- ```CheckConstraint `` <https://docs.djangoproject.com/en/stable/ref/models/constraints/#checkconstraint>`__
136
+ `PositiveIntegerField
137
+ <https://docs.djangoproject.com/en/stable/ref/models/fields/#positiveintegerfield> `__
138
+ and `CheckConstraint
139
+ <https://docs.djangoproject.com/en/stable/ref/models/constraints/#checkconstraint> `__
149
140
can't be used.
150
141
151
142
``DecimalField `` isn't supported
@@ -185,7 +176,7 @@ Spanner has some limitations on schema changes which you must respect:
185
176
- Renaming tables and columns isn't supported.
186
177
- A column's type can't be changed.
187
178
- A table's primary key can't be altered.
188
- - Migrations aren't atomic since django -spanner doesn't support
179
+ - Migrations aren't atomic since `` python -spanner-django `` doesn't support
189
180
transactions.
190
181
191
182
``DurationField `` arithmetic doesn't work with ``DateField `` values (`#253 <https://github.com/googleapis/python-spanner-django/issues/253 >`__)
@@ -247,6 +238,3 @@ Internals
247
238
248
239
.. figure :: ./assets/internals.png
249
240
:alt:
250
-
251
- 🚨🚨THIS CODE IS STILL UNDER DEVELOPMENT🚨🚨
252
- ============================================
0 commit comments