At this time we’re blissful to announce GA help for Google Cloud Spanner within the Django ORM. The django-google-spanner bundle is a third-party database backend for Cloud Spanner, powered by the Cloud Spanner Python shopper library. The Django ORM is a strong standalone part of the Django net framework that maps Python objects to relational knowledge. It offers a pleasant Pythonic interface to the underlying database, and contains instruments for robotically producing schema modifications and managing schema model historical past. With this integration, Django functions can now make the most of Cloud Spanner’s excessive availability and consistency at scale.
We’ll observe the Django tutorial beneath to create a brand new challenge and begin writing knowledge to Cloud Spanner. It is a observe as much as the “Introducing Django ORM help for Cloud Spanner” weblog put up, which we revealed throughout the Beta launch. We have now up to date the tutorial to work with the Django three.2 library.
In the event you’re already utilizing Django with one other database backend you may skip all the way down to “Migrating an current Django challenge to Cloud Spanner” for directions on switching to Cloud Spanner. It’s also possible to learn the documentation right here, and observe the repository right here.
Modifications because the Beta launch
The library helps Django model 2.2.x, and three.2.x. Each variations are long-term help (LTS) releases for the Django challenge. The minimal required Python model is three.6.
NUMERIC knowledge sort help is now out there. We have now additionally added help for JSON object storage and retrieval with Django three.2.x help, however querying contained in the JSONfield just isn’t supported within the present
django-google-spanner launch. This function is being labored on and will be tracked right here.
PositiveBigIntegerField, PositiveIntegerField and
PositiveSmallIntegerField had been added together with related verify constraints.
To make use of
django-google-spanner, you may want a working Python set up and Django challenge. The library requires Django~=2.2 or
Python>=three.6. In the event you’re new to Django, see the Django getting began information particular to the Django model you’re utilizing. For the tutorial beneath we might be utilizing
Django~=three.2 however the course of is comparable for
Django~=2.2 as properly.
You may additionally want an lively Google Cloud challenge with the Cloud Spanner API enabled. For extra particulars on getting began with Cloud Spanner see the Cloud Spanner getting began information.
Django functions are sometimes configured to make use of a single database. In the event you’re an current Cloud Spanner buyer, it is best to have already got a database appropriate to be used together with your Django software. In the event you do not have already got a Cloud Spanner database, or need to begin from scratch for a brand new Django software, you may create a brand new occasion and database utilizing the Google Cloud SDK: