Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between google.appengine.ext.ndb and gcloud.datastore?

ndb: (from google.appengine.ext import ndb)

datastore: (from gcloud import datastore)

What's the difference? I've seen both of them used, and hints they both save data to google datastore. Why are there two different implementations?

like image 668
invapid Avatar asked Sep 11 '16 23:09

invapid


People also ask

What is cloud NDB?

App Engine NDB enables Python 2 apps to store and query data in Datastore databases. Cloud NDB enables Python 2 and Python 3 apps to store and query data in the same databases, however the product that manages those databases has changed from Datastore to Firestore in Datastore mode (Datastore).

What is NDB in App Engine?

The Google Datastore NDB Client Library allows App Engine Python apps to connect to Datastore. The NDB client library builds on the older DB Datastore library adding the following data store features: The StructuredProperty class, which allows entities to have nested structure.


2 Answers

The Python NDB Client is specific to Python Applications running on Google App Engine. The datastore client removes that restriction and you can run your Python application anywhere, including Google App Engine, Google Compute Engine or anywhere else.

Exceprt form - https://cloud.google.com/appengine/docs/python/ndb/

The Google Datastore NDB Client Library allows App Engine Python apps to connect to Cloud Datastore.

In addition, the NDB client has certain features (e.g. caching) while the other does not appeat to support.

like image 194
Sai Pullabhotla Avatar answered Sep 22 '22 08:09

Sai Pullabhotla


The reason for the two implementations is that originally, the Datastore (called App Engine Datastore) was only available from inside App Engine (through a private RPC API). On Python, the only way to access this API was through an ORM-like library (NDB). As you can see on the import, it is part of the App Engine API.

Now Google has made the Datastore available outside of App Engine through a restful API called Cloud Datastore API. gcloud library is a client library that allows access to different rest APIs from Google Cloud, including the Cloud Datastore API.

like image 43
dyeray Avatar answered Sep 22 '22 08:09

dyeray