Message Boards Message Boards

0
|
11499 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Cloud FormFunction Database

Posted 8 years ago

I am trying to build a web inventory application using a SQLite database hosted in the cloud home directory. I have a database in the home directory and I can query that database while in the code editor but when I publish to a webform the code does not work.

Needs["DatabaseLink`"];
dbFilePath="/wolframcloud/userfiles/********";
conn=OpenSQLConnection[JDBC["SQLite",dbFilePath]]

SQLSelect[conn, "key"]

works file when I am in the notebook. I then go to deploy it to the cloud..

CloudDeploy[FormFunction["Table" -> {"key"-> "key","eltesting"-> "eltesting"},SQLSelect[conn,#Table]&]]

It looks great enter image description here

Then when I press submit I get response:

DatabaseLink`SQLSelect[DatabaseLink`SQLConnection[DatabaseLink`JDBC["SQLite", "******"], JLink`Objects`vm1`JavaObject10700769468612609, 6, "Catalog" -> Automatic, "Description" -> None, "Location" -> None, "Name" -> None, "Password" -> None, "Properties" -> {}, "ReadOnly" -> Automatic, "RelativePath" -> False, "TransactionIsolationLevel" -> Automatic, "UseConnectionPool" -> Automatic, "Username" -> None, "Version" -> None], "key"]

I have replaced my file path with ****** for security. If local database storage is not supported what is the best way for my application to store, update and retrieve data. DataDrop is not the correct solution as I need this data to last more than 30 days.

POSTED BY: Ray Troy
6 Replies

Ray, Yep this is what I meant. It should work. But I think because of the new

$SessionID

as a result of the FormFunction your are not allowed to setup the jdbc ip-connection. The following produces a Failed message.

CloudDeploy@FormFunction["f" -> "String", (Needs["DatabaseLink`"];OpenSQLConnection["demo"])&]

Would be nice if I could generate a warning message...

Sorry, just saw I can reply directly to you. Please see below.

POSTED BY: Ray Troy

Sorry, just saw I can reply directly to you. Please see below.

POSTED BY: Ray Troy
POSTED BY: Ray Troy

If you do CloudEvaluate[something, Hold] you get back the expression after it was evaluated on the cloud.

do it with your connection / db select in order to debug what is going on. database connection in the cloud is coming, but in the mean time CloudExpression is a powerful keyvalue storage that is backed by redis. If a key value store is enough for your application, CloudExpression is what you should use.

Hello Ray, You need to reload Needs["DatabaseLink"] and reopen the connection conn before launching a SQLSelect. Btw use full context to make the DatabaseLinkSQLSelect call. The reason for this is that every time you launch a Form a new cloudkernel is used (check kernel sessionid).

good luck.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract