Error when using select

12 views
Skip to first unread message

Craig B

unread,
Sep 24, 2009, 11:47:22 PM9/24/09
to Sublime SimpleDB
I am just taking a look and trying the example code on the main page,
but I get an exception trying to run a trivial select query. This is
the test code I am using:

import org.sublime.amazon.simpleDB.api._
class ShowConfiguration {
def show = {
val account = new SimpleDBAccount( "xxxxx", "xxxxx")
import account._
select( "select * from 'my-domain' where id = '1'") foreach ( e =>
println( e))
}
}

which results in this trace:

Message: org.sublime.amazon.simpleDB.Exceptions
$InvalidQueryExpression: InvalidQueryExpression: The specified query
expression syntax is not valid. (1.372E-5s)
org.sublime.amazon.simpleDB.Exceptions$.makeException(Errors.scala:
211)
org.sublime.amazon.simpleDB.Exceptions$.toException(Errors.scala:158)
org.sublime.amazon.simpleDB.Connection$$anonfun$makeRequest$1.apply
(Net.scala:76)
org.sublime.amazon.simpleDB.Connection$$anonfun$makeRequest$1.apply
(Net.scala:69)
org.sublime.amazon.simpleDB.ConnectionPool.exec(Net.scala:45)
org.sublime.amazon.simpleDB.Connection.makeRequest(Net.scala:69)
org.sublime.amazon.simpleDB.api.SimpleDBAccount.makeSimpleDBRequest
(Account.scala:26)
org.sublime.amazon.simpleDB.Concrete$SelectRequest.response
(Concrete.scala:141)
org.sublime.amazon.simpleDB.api.SimpleAPI$class.select
(SimpleAPI.scala:450)
org.sublime.amazon.simpleDB.api.SimpleAPI$class.select
(SimpleAPI.scala:418)
org.sublime.amazon.simpleDB.api.SimpleDBAccount.select(Account.scala:
23)
.......


Has anyone seen this before?

Thanks,
Craig

Craig B

unread,
Sep 25, 2009, 11:25:51 AM9/25/09
to Sublime SimpleDB
Found my own answer. The example code on the Wiki is incorrect -
including "select" in the expression results in it appearing twice in
the request.

Robin Barooah

unread,
Sep 25, 2009, 1:12:36 PM9/25/09
to Sublime SimpleDB
You're right! Thanks for catching that. I've updated the wiki.

There is also a typesafe DSL for constructing select queries which
I've found a lot more convenient than constructing the select queries
manually.

The code has a reasonable amount of javadoc, but I haven't written an
introduction or other proper documentation yet.

Here are some snippets from a simple (working) blog example:

import org.sublime.amazon.simpleDB.api._
import org.sublime.Conversions._
import org.sublime.Attributes._
import org.sublime.amazon.simpleDB.Select._

/** YOU CAN DEFINE A TYPED 'RECORD' (REALLY JUST A GROUP OF
ATTRIBUTES) **/

object PostingRecord {
/** Attributes used in simpleDB **/
val title = attribute("title")
val author = attribute("author")
val tags = attribute("tags")
val date = attribute("date", ISO8601Date)
}

// Get a reference to the the domain where the postings are to
be stored
val postings = account domain "postings"

// and make sure it exists
postings create

// updates are identified as such by a tag
val updateTag = "update"

/** THEN YOU CAN DEFINE QUERIES USING SCALA **/

// query for the index of postings
def index = postings (((tags is updateTag) intersection (date
< new java.util.Date)) order_by date desc)

/** INDEX IS A FUNCTION THAT CREATES A SELECT QUERY AND EXECUTES IT
EACH TIME IT'S CALLED **/

def buildPostings {
for (entry <- index) buildPosting(entry)

Craig B

unread,
Sep 28, 2009, 2:11:10 PM9/28/09
to Sublime SimpleDB
Vey cool! I'd definitely prefer to go that way, will give it a shot
as soon as I can.

Thanks,
Craig
Reply all
Reply to author
Forward
0 new messages