0

I'm attempting to periodically push data to a fusion table, and I have everything working except for the ability to insert the time portion of a DATETIME.

It works as expected if I omit the datetime field all together, e.g.:

service.query().sql(sql='INSERT INTO <my table> (Humidity, Temperature, Luminosity) VALUES (40, 70, 100)')

However, I get a synatx error every time I attempt to write the date. If I separate the date with /'s, it errors on those, so I switched to -'s, which seems to appease it. Only now, it chokes on the :'s that separate hour from minute:

service.query().sql(sql='INSERT INTO <my table> (Date, Humidity, Temperature, Luminosity) VALUES (04-12-2014 13:51, 40, 70, 100)')

yields:

HttpError: <HttpError 400 when requesting https://www.googleapis.com/fusiontables/v1/query?alt=json&sql=INSERT+INTO+(my table id)+%28Date%2C+Humidity%2C+Temperature%2C+Luminosity%29+VALUES+%2804-12-2014+13%3A51%2C+40%2C+70%2C+100%29 returned "Invalid query: Parse error near ':' (line 1, position 117).">

There's only one ':', so it's gotta be the time separator. Is there some other character I should be using to separate hours from minutes? Does it need to be escaped somehow? All of examples I can find in Google's documentation don't interact with DATETIME's.

When I tried without a ':' at all (e.g., 04-12-2014 1351), it didn't throw an error, but the date was interpreted in a wildly inaccurate way (09/01/1351).

Thanks!

Kevin W.
  • 3
  • 1

1 Answers1

0

Have you tried adding quotation marks around datetime?

etna
  • 1,083
  • 7
  • 13
  • Yes, sorry I forgot to mention that. I've tried it with and without double quotes around the date expression. It doesn't seem to make a difference one way or the other, so I've been omitting them. Is there some way in particular I should be using them? – Kevin W. Apr 16 '14 at 00:33
  • Turns you you were on the right track, thank you for inspiring me to check the quoting again! I found [this post](http://stackoverflow.com/questions/15326640/how-do-i-insert-a-row-in-my-google-fusion-table-using-python), which detailed some obscure rules for using the API. Rule #3 says: "Must use double quotes with single quotes inside..." Sure enough, that allows for a ':' inside of the DATETIME to delimit the hours/minutes. – Kevin W. Apr 16 '14 at 00:58