Entität in Google Cloud Datastore speichern mit Python: Ein minimales Beispiel
English
Deutsch
Hier ist ein minimales Beispiel zum Einfügen einer Entität in die Google Cloud Datastore-Objektdatenbank mit der Python-API:
datastore_save_example.py
#!/usr/bin/env python3
from google.cloud import datastore
# Entität erstellen & speichern
client = datastore.Client(project="myproject-12345")
entity = datastore.Entity(key=client.key('MyEntityKind', 'MyTestID'))
entity.update({
'foo': u'bar',
'baz': 1337,
'qux': False,
})
# Entität tatsächlich speichern
client.put(entity)Dies setzt voraus, dass du bereits eine Entitätsart mit dem Namen MyEntityKind im Projekt mit der ID myproject-12345 erstellt hast.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow