Is there a possible way to have two datastores for the same application?

184 views
Skip to first unread message

youssef dehbi alaoui

unread,
Apr 11, 2016, 9:20:34 AM4/11/16
to Google App Engine
hi everyone i need in my application two types of data (but same entities), one for testing and the other for production... so i'm wondering if there is a solution to make a difference between these two types like having two datastores???? 
Thanks.

Anastasios Hatzis

unread,
Apr 11, 2016, 10:23:25 AM4/11/16
to Google App Engine
Youssef, if I remember correctly, you can only have one datastore and one app-engine in a Google cloud project. However, you should be able to access entities of a different datastore (i.e. in a different project) by defining the app parameter in the NDB Key constructor. Certainly, you would need to manually add permissions for your app in the other (test) datastore.

Alternatively, you could use just the same datastore, but a different namespace, e.g. "test". Or if you already use namespaces for multi-tenancy, you could have multiple namespaces test-1, test-2 etc. to run tests regarding multi-tenancy features.

Ani

youssef dehbi alaoui

unread,
Apr 11, 2016, 11:01:58 AM4/11/16
to Google App Engine
thank you Anastasios Hatzis for your help :)

Nick

unread,
Apr 11, 2016, 6:31:56 PM4/11/16
to Google App Engine
While you could use namespaces to achieve this, you need to consider what it means to have two 'environments' running together, and what are the consequences of mistakes.

Generally we've found the simplest option is to have extra cloud projects for extra environments, which is usually very cheap/free assuming you aren't simulating real loads constantly. Obviously there are some drawbacks to this, such as ease of code promotion, but if you're using other services in google cloud, they aren't intrinsically namespace aware, so you need to be careful.

Karl MacMillan

unread,
Apr 11, 2016, 8:21:16 PM4/11/16
to google-a...@googlegroups.com


On Apr 11, 2016, at 6:31 PM, Nick <naok...@gmail.com> wrote:

While you could use namespaces to achieve this, you need to consider what it means to have two 'environments' running together, and what are the consequences of mistakes.

Generally we've found the simplest option is to have extra cloud projects for extra environments, which is usually very cheap/free assuming you aren't simulating real loads constantly. Obviously there are some drawbacks to this, such as ease of code promotion, but if you're using other services in google cloud, they aren't intrinsically namespace aware, so you need to be careful.


We use separate projects as well and it works reasonably well. It makes it much less stressful to push builds to the test environment. 

Unfortunately you are likely to need some sort of mechanism to change configuration between environments. For example, if you use google cloud storage, bucket names must be globally unique so you have to store or derive the root bucket names for each environment. 

Karl

On Monday, April 11, 2016 at 11:20:34 PM UTC+10, youssef dehbi alaoui wrote:
hi everyone i need in my application two types of data (but same entities), one for testing and the other for production... so i'm wondering if there is a solution to make a difference between these two types like having two datastores???? 
Thanks.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/b51ace6a-b8c5-4404-97eb-6793408f4027%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

youssef dehbi alaoui

unread,
Apr 12, 2016, 10:06:40 AM4/12/16
to Google App Engine
Thanks Nick and Karl for the help.. we choose to have two application and manage it separately...
Reply all
Reply to author
Forward
0 new messages