views:

135

answers:

2

I've just started playing with Google App Engine using php via Quercus.

I'm not going to be moving my complete app over to app engine, but am thinking of serving up some widgets and api stuff via app engine. At the same time, I will be maintaining my databases in mysql as I've got that running on a seperate server.

I make all sorts of different shaped data requests against my database. Stuff like get by date within lat/longs, get by user, etc. etc.

Most of the widget and api requests I suspect will continue to be for the same 300-400 queries. I don't think it makes sense to move all my data over to app engine, and end up storing the data in two places.

I was hoping I could pose queries via php to an external mysql server, but apparently that doesn't work. I get the following error when trying to connect

Warning: A link to the server could not be established. url=jdbc:mysql://localhost:3306/
. which I assume means that app engine can't connect to mysql due to app engine settings, not due to anything specifically that I have done wrong. I have checked that mysql is running on port 3306.

Assuming the issue is that App Engine can't connect to mysql (even an external mysql database), I'm thinking my other option would be to retrieve the data in json and store that in the app engine memcache, or directly in the datastore as a complete json object, and then hash the query to use as a key to retrieve the data.

I'm hoping to get some advice as to if this is the right way (or I guess a good way) of managing data on AppEngine, or is there another solution I should be looking at.

I am a bit surprised that app engine can't make requests to an external relational database, as I thought the responses are retrieved as objects, and the 'relationship' doesn't exist beyond mysql.

+1  A: 

Well, one thing is for sure: forget about MySQL on AppEngine.

The Datastore will probably be the fastest since it is integrated in the platform. You can of course use an HTTP interface to an external DB if you like...

jldupont
I don't believe I'm familiar with an http interface to an external DB, but rest-assured, I was never trying to get MySQL 'ON' AppEngine, just connect to a MySQL database. However, my searches for 'HTTP interface to an external DB ' are not coming up with much. Do i just open port 3306? is this safe?If you have a good resource, I'd be greatful.
pedalpete
I was referring to a database such as Amazon's SimpleDB which can be interfaced with through HTTP.
jldupont
:( right, but that doesn't help with the 'one storage engine' problem, and my understanding of SimpleDB is that it is non-relational, like App Engine's datastore.
pedalpete
... it was just a suggestion. If I were you, I'd seriously look into the Datastore... or move to something else than AppEngine.
jldupont
+2  A: 

You can't make socket connections on App Engine - only HTTP requests. Your best options are either to mirror the relevant data to App Engine, or to have your old app provide an API that exposes the relevant data, and call it from your App Engine app.

Nick Johnson
Thanks Nick, I think it was the 'socket' connection piece that I was missing, now I understand why this isn't possible. I've already built an API, so I'll just use that to transfer the data.
pedalpete