Skip to main content

Posts

Showing posts with the label Database

How to delete all records from a Google Cloud Datastore Entity?

Google has recently given a new feature known as 'Dataflow Templates' which have got a number of tasks that you can do without writing any code.   Click the link on top of Dataflow page: You can select task from the list of available options: Select 'Bulk Delete Entities in Cloud Datastore' from the list.  Fill in the required parameters. Instead of table name, it asks for GQL query. For selecting all the entities in a table give "select * from " . IMPORTANT: In the optional parameters, you should specify the namespace/tenant for which you want to delete the entities.  Not specifying namespace will delete ALL the records from the selected table across the tenants .  Once done, press 'Run Job'. Dataflow will launch and do the cleanup. You can read documentation  here . Source code of all templates is also on  github .

How to query data using GQL if your Kind name has a dot in it?

There is a big chance that your kind (table) name is of the format . because there are various tables in your module. e.g. I had StoreService.Store and StoreService.Employee as two of the kinds in my service named StoreService. In Google Cloud Console, if you write a GQL to query to fetch/filter the entities you will get an error: SELECT * from StoreService.Store GQL query error:  Encountered "." at line 1, column 27. Was expecting one of: "group", "limit", "offset", "order", "where" Enclosing the Kind name in single quotes doesn't help either: SELECT * from 'StoreService.Store' GQL query error:  Encountered "'StoreService.Store'" at line 1, column 15. Was expecting one of: , To do it right, you need to enclose the name in backquotes (that key below ~ in the keyboard)!!! SELECT * from `StoreService.Store` This information is hidden in Datastore documentation here . Try finding i...

How to transfer data from Cloud Datastore to Big Query in Google Cloud Platform

If you are here I am assuming that you are looking to migrate the data from Cloud Datastore to Big Query because you want to do some analysis and are frustrated by limitations imposed by GQL (Google Query Language). First of all you need to create a backup of the data in datastore. Use the Datastore Admin tool provided by Google to take a backup and store it automatically in the Cloud Storage bucket. Select all the entities and press 'Backup Entities'. Give a backup name, select Google Cloud Storage as backup storage destination and specify a bucket name. Once the backup job is completed, you will see the backup listed. You can select a backup and press 'Info' and see the details (Entities are masked in the screenshot below). Go to the bucket mentioned in 'Handle' and you will see the file mentioned above. You will also see many more files with similar names, ending with .backup_info (e.g. ahRzfmpkYS1wZC1zbG8tc2FuZGJveHJBCxIcX0FFX0RhdGFzdG9yZUFk...