1
0
Fork 0

Correct INSERT examples

master
Philip O Toole 9 years ago
parent 9eb80b7a29
commit dad669fb04

@ -55,7 +55,7 @@ where `curl` is the [well known command-line tool](http://curl.haxx.se/). Passin
To insert an entry into the database, execute a second SQL command: To insert an entry into the database, execute a second SQL command:
curl -L -XPOST 'localhost:4001/db?pretty&explain' -d '[ curl -L -XPOST 'localhost:4001/db?pretty&explain' -d '[
"INSERT INTO foo(name) VALUES('fiona')" "INSERT INTO foo(name) VALUES(\"fiona\")"
]' ]'
The use of the URL param `pretty` is optional, and results in pretty-printed JSON responses. `explain` is also optional. If included, the response will include some basic information about the processing that took place -- how long it took, for example. The use of the URL param `pretty` is optional, and results in pretty-printed JSON responses. `explain` is also optional. If included, the response will include some basic information about the processing that took place -- how long it took, for example.
@ -75,16 +75,16 @@ Note that this is the SQLite file that is under `node 3`, which is not the node
Bulk updates are supported. To execute multipe statements in one HTTP call, simply include the statements in the JSON array: Bulk updates are supported. To execute multipe statements in one HTTP call, simply include the statements in the JSON array:
curl -L -XPOST 'localhost:4001/db?pretty' -d '[ curl -L -XPOST 'localhost:4001/db?pretty' -d '[
"INSERT INTO foo(name) VALUES('fiona')", "INSERT INTO foo(name) VALUES(\"fiona\")",
"INSERT INTO foo(name) VALUES('sinead')" "INSERT INTO foo(name) VALUES(\"sinead\")"
]' ]'
#### Transactions #### Transactions
Transactions are supported. To execute statements within a transaction, add `transaction` to the URL. An example of the above operation executed within a transaction is shown below. Transactions are supported. To execute statements within a transaction, add `transaction` to the URL. An example of the above operation executed within a transaction is shown below.
curl -L -XPOST 'localhost:4001/db?pretty&transaction' -d '[ curl -L -XPOST 'localhost:4001/db?pretty&transaction' -d '[
"INSERT INTO foo(name) VALUES('fiona')", "INSERT INTO foo(name) VALUES(\"fiona\")",
"INSERT INTO foo(name) VALUES('sinead')"" "INSERT INTO foo(name) VALUES(\"sinead\")""
]' ]'
When a transaction takes place either both statements will succeed, or neither. Performance is *much, much* better if multiple SQL INSERTs or UPDATEs are executed via a transaction. When a transaction takes place either both statements will succeed, or neither. Performance is *much, much* better if multiple SQL INSERTs or UPDATEs are executed via a transaction.

Loading…
Cancel
Save