You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
27
+
Using this library requires a Google Cloud Platform project with the Cloud
28
+
Spanner API enabled. See the Spanner Python client `documentation
14
29
<https://github.com/googleapis/python-spanner/#quick-start>`__ for details.
15
30
16
-
Use the version of ``django-google-spanner`` that corresponds to your version
31
+
The version of ``django-google-spanner`` must correspond to your version
17
32
of Django. For example, ``django-google-spanner`` 2.2.x works with Django
18
-
2.2.y. (This is the only supported version at this time.)
33
+
2.2.y (Note: this is the only supported version at this time).
19
34
20
-
The minor release number of Django doesn't correspond to the minor release
21
-
number of ``django-google-spanner``. Use the latest minor release of each.
35
+
The minor release numbers of Django may not correspond to the minor release
36
+
numbers of ``django-google-spanner``. Use the latest minor release of each.
22
37
23
38
To install from PyPI:
24
39
@@ -36,15 +51,14 @@ To install from source:
36
51
pip3 install -e .
37
52
38
53
39
-
Usage
40
-
-----
54
+
Configuring ``settings.py``
55
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
41
56
42
-
After `installation <#Installation>`__, you'll need to edit your Django
43
-
``settings.py`` file:
57
+
After `installation <#Installation>`__, you'll have to update your Django
58
+
``settings.py`` file as follows.
44
59
45
60
- Add ``django_spanner`` as the very first entry in the ``INSTALLED_APPS``
46
-
setting
47
-
61
+
settings:
48
62
49
63
.. code:: python
50
64
@@ -53,49 +67,43 @@ After `installation <#Installation>`__, you'll need to edit your Django
53
67
...
54
68
]
55
69
56
-
- Edit the ``DATABASES`` setting to point to an EXISTING database
57
-
58
-
Format
59
-
~~~~~~
70
+
- Edit the ``DATABASES`` settings to point to an EXISTING database, as shown in the following example:
60
71
61
-
.. code:: python
62
-
63
-
DATABASES= {
64
-
'default': {
65
-
'ENGINE': 'django_spanner',
66
-
'PROJECT': '<project_id>',
67
-
'INSTANCE': '<instance_id>',
68
-
'NAME': '<database_name>',
69
-
# Only include this if you need to specify where to retrieve the
70
-
# service account JSON for the credentials to connect to Cloud Spanner.
71
-
'OPTIONS': {
72
-
'credentials_uri': '<credentials_uri>',
73
-
},
74
-
},
75
-
}
76
-
77
-
Database configurations
78
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79
-
80
-
.. code:: python
81
-
82
-
DATABASES= {
83
-
'default': {
84
-
'ENGINE': 'django_spanner',
85
-
'PROJECT': 'appdev-soda-spanner-staging', # Or the GCP project-id
86
-
'INSTANCE': 'django-dev1', # Or the Cloud Spanner instance
87
-
'NAME': 'db1', # Or the Cloud Spanner database to use
88
-
}
89
-
}
72
+
.. code:: python
90
73
91
-
Execute a query
92
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
+
DATABASES= {
75
+
'default': {
76
+
'ENGINE': 'django_spanner',
77
+
'PROJECT': '<GCP_project_id>',
78
+
'INSTANCE': '<instance_id>',
79
+
'NAME': '<database_name>',
80
+
}
81
+
}
82
+
83
+
- In order to retrieve the Cloud Spanner credentials from a JSON file, the ``credentials_uri`` parameter can also be supplied in the ``OPTIONS`` field:
@@ -177,7 +177,7 @@ This feature uses a column name that starts with an underscore
177
177
Random ``QuerySet`` ordering isn't supported
178
178
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
179
179
180
-
Spanner doesn't support it. For example:
180
+
Spanner does not support it and will throw an exception. For example:
181
181
182
182
::
183
183
@@ -189,13 +189,11 @@ Spanner doesn't support it. For example:
189
189
Schema migrations
190
190
~~~~~~~~~~~~~~~~~
191
191
192
-
Spanner has some limitations on schema changes which you must respect:
192
+
There are some limitations on schema changes to consider:
193
193
194
-
- Renaming tables and columns isn't supported.
195
-
- A column's type can't be changed.
194
+
- No support for renaming tables and columns;
195
+
- A column's type can't be changed;
196
196
- A table's primary key can't be altered.
197
-
- Migrations aren't atomic since ``django-google-spanner`` doesn't support
198
-
transactions.
199
197
200
198
``DurationField`` arithmetic doesn't work with ``DateField`` values (`#253 <https://github.com/googleapis/python-spanner-django/issues/253>`__)
0 commit comments