Title: Feels like we've added a bit more complexity to the datastore API, comments? · Issue #647 · googleapis/google-cloud-python · GitHub
Open Graph Title: Feels like we've added a bit more complexity to the datastore API, comments? · Issue #647 · googleapis/google-cloud-python
X Title: Feels like we've added a bit more complexity to the datastore API, comments? · Issue #647 · googleapis/google-cloud-python
Description: Hi guys, I was reviewing the "state of the world" of the datastore API, and found a few things that seem (to me at least) a bit more complicated than they should be. A bit of this comes from the authentication stuff (which we have anothe...
Open Graph Description: Hi guys, I was reviewing the "state of the world" of the datastore API, and found a few things that seem (to me at least) a bit more complicated than they should be. A bit of this comes from the au...
X Description: Hi guys, I was reviewing the "state of the world" of the datastore API, and found a few things that seem (to me at least) a bit more complicated than they should be. A bit of this comes f...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/647
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feels like we've added a bit more complexity to the datastore API, comments?","articleBody":"Hi guys,\n\nI was reviewing the \"state of the world\" of the datastore API, and found a few things that seem (to me at least) a bit more complicated than they should be.\n\nA bit of this comes from the authentication stuff (which we have another open bug for) but I wanted to bring up a few things for discussion... If this issue gets out of control, we can move the discussion elsewhere, but I wanted to kick things off:\n### Create a new Person entity in the Datastore\n#### What I have to write\n\n``` python\nfrom gcloud import datastore\ndatastore.set_defaults()\nentity = datastore.Entity(key=datastore.Key('Person'))\nentity.update({'name': 'Jimmy'})\ndatastore.put([entity])\n```\n#### What I'd like to write\n\n``` python\nfrom gcloud import datastore\nentity = datastore.Entity('Person')\nentity.update({'name': 'Jimmy'})\nentity.put()\n```\n#### Key differences\n1. no `set_defaults()` (there's another issue open for this I believe)\n2. Create an entity of kind Person without lots more typing (or maybe we get the entity with `datastore.Kind('Person').get_entity()` ?)\n3. `.put` not requiring a list for a single entity\n### Get an existing Person (123) from the Datastore\n#### What I have to write\n\n``` python\nfrom gcloud import datastore\ndatastore.set_defaults()\nentity = datastore.get(datastore.Key('Person', 123))\n```\n#### What I'd like to write\n\n``` python\nfrom gcloud import datastore\ndatastore.set_defaults()\nentity = datastore.Kind('Person').get_by_id(123)\n```\n#### Key differences\n1. No `set_defaults`\n2. Equivalent of \"drilling down\" into a \"table\" (kind), and then a \"row\" (id)\n\n_(Not hugely concerned about this use case, but wanted to toss it out)_\n### Create a new Person using a specific set of credentials (`/home/creds.json`) to talk to a specific dataset (`'my-dataset'`) in the Datastore\n\n(Being looked into in PR https://github.com/GoogleCloudPlatform/gcloud-python/pull/641)\n#### What I have to write\n\n_(This is a best guess... I don't know if this code is even right... And even so, this code won't do the same thing if you ran it on App Engine because of the order of evaluation here: http://googlecloudplatform.github.io/gcloud-python/latest/gcloud-api.html#gcloud.credentials.get_credentials )_\n\n``` python\nimport sys\nsys.env['GOOGLE_APPLICATION_CREDENTIALS'] = '/home/creds.json'\n\nfrom gcloud import datastore\ndatastore.set_defaults()\nentity = datastore.Entity(key=datastore.Key('Person', dataset_id='my-dataset'))\nentity.update{'name': 'Jimmy'})\ndatastore.put(entity)\n```\n#### What I'd like to write\n\n``` python\nfrom gcloud import datastore\ndatastore.set_credentials('/home/creds.json')\ndataset = datastore.Dataset('my-dataset')\nentity = dataset.Entity('Person')\nentity.update({'name': 'Jimmy'})\nentity.put()\n```\n#### Key differences\n1. Simple in-code way to set which credentials file to use\n2. High-level concept of a dataset\n3. Datasets can provide Entities just like `datastore` would\n\n/cc @tseaver @dhermes @pcostell \n","author":{"url":"https://github.com/jgeewax","@type":"Person","name":"jgeewax"},"datePublished":"2015-02-15T19:02:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/647/google-cloud-python/issues/647"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7d509747-21a3-b711-7bc7-b91ef2101c81 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 817E:ED0C6:171E0D3:2012647:6A4DF69A |
| html-safe-nonce | 89f019f5f6377512c1e359bb5549daf81992e4275c739f81f837503ab0de4f0b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTdFOkVEMEM2OjE3MUUwRDM6MjAxMjY0Nzo2QTRERjY5QSIsInZpc2l0b3JfaWQiOiIzNzc5ODEwNjgyNzQxNjk0OTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 960681e4ac376968253af3dc11ccb33a09d831f0c038784860ee3a139a3f6759 |
| hovercard-subject-tag | issue:57741401 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/647/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e8549b045d218095014b6cd6b282fb96494bba3a770678a794847d6b99139944/googleapis/google-cloud-python/issues/647 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e8549b045d218095014b6cd6b282fb96494bba3a770678a794847d6b99139944/googleapis/google-cloud-python/issues/647 |
| og:image:alt | Hi guys, I was reviewing the "state of the world" of the datastore API, and found a few things that seem (to me at least) a bit more complicated than they should be. A bit of this comes from the au... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jgeewax |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 16316451 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16316451 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f4bb89367ca678f057d79b1abc45d6675b1bd5b2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width