You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-17Lines changed: 19 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,17 @@
1
-
# mod-mysql-postgresql
1
+
# Vert.x 2.x is **deprecated** - use instead http://vertx.io/docs/vertx-mysql-postgresql-client/java/
2
+
3
+
## mod-mysql-postgresql
2
4
3
5
This Vert.x module uses the https://github.com/mauricio/postgresql-async drivers to support a fully async module for MySQL and PostgreSQL.
4
6
5
-
## Requirements
7
+
###Requirements
6
8
7
9
* Vert.x 2.1+ (with Scala language module v1.1.0+)
8
10
* A working PostgreSQL or MySQL server
9
11
* For testing PostgreSQL: A `testdb` database on a local PostgreSQL install and a user called `vertx`
10
12
* For testing MySQL: A `testdb` database on a local MySQL install and a user called `root`
11
13
12
-
## Installation
14
+
###Installation
13
15
14
16
Depending on your Scala version, you should download the specific version. If you're using Scala 2.10.x:
15
17
@@ -27,7 +29,7 @@ If you get `java.lang.ClassNotFoundException: org.vertx.scala.core.VertxAccess$c
27
29
28
30
If you're using Scala in your own project and want to use Scala 2.11, you can change `lang-scala_2.10` to `lang-scala_2.11`.
29
31
30
-
## Configuration
32
+
###Configuration
31
33
32
34
{
33
35
"address" : <event-bus-addres-to-listen-on>,
@@ -50,13 +52,13 @@ If you're using Scala in your own project and want to use Scala 2.11, you can ch
50
52
*`database` - The name of the database you want to connect to. Defaults to `testdb`.
51
53
52
54
53
-
## Usage
55
+
###Usage
54
56
55
57
All commands are relatively similar. Use JSON with the `action` field and add the needed parameters for each command.
56
58
57
59
There are only a few commands available currently, but in theory you should be able to invoke any command on the database with the `raw` action.
58
60
59
-
### Reply messages
61
+
####Reply messages
60
62
61
63
The module will reply to all requests. In the message, there will be either a `"status" : "ok"` or a `"status" : "error"`. If the request could be processed without problems, it will result in an "ok" status. See an example here:
62
64
@@ -83,7 +85,7 @@ If the request resulted in an error, a possible reply message looks like this:
83
85
"message" : "column \"ager\" does not exist"
84
86
}
85
87
86
-
### insert
88
+
####insert
87
89
88
90
Use this action to insert new rows into a table. You need to specify a table, the fields to insert and an array of rows to insert. The rows itself are an array of values.
89
91
@@ -97,7 +99,7 @@ Use this action to insert new rows into a table. You need to specify a table, th
97
99
]
98
100
}
99
101
100
-
### select
102
+
####select
101
103
102
104
The `select` action creates a `SELECT` statement to get a projection from a table. You can filter the columns by providing a `fields` array. If you omit the `fields` array, it selects every column available in the table.
103
105
@@ -107,7 +109,7 @@ The `select` action creates a `SELECT` statement to get a projection from a tabl
Creates a prepared statement and lets you fill the `?` with values.
113
115
@@ -117,7 +119,7 @@ Creates a prepared statement and lets you fill the `?` with values.
117
119
"values" : ["Mr. Test", 15]
118
120
}
119
121
120
-
### raw - Raw commands
122
+
####raw - Raw commands
121
123
122
124
Use this action to send arbitrary commands to the database. You should be able to submit any query or insertion with this command.
123
125
@@ -143,39 +145,39 @@ And if you want to drop it again, you can send the following:
143
145
"command" : "DROP TABLE some_test;"
144
146
}
145
147
146
-
### Transactions
148
+
####Transactions
147
149
148
150
These commands let you begin a transaction and send an arbitrary number of statements within the started transaction. You can then commit or rollback the transaction.
149
151
Nested transactions are not possible until now!
150
152
151
153
Remember to reply to the messages after you send the `begin` command. Look in the docs how this works (e.g. for Java: [http://vertx.io/core_manual_java.html#replying-to-messages](http://vertx.io/core_manual_java.html#replying-to-messages)).
152
154
With replying to the messages, the module is able to send all statements within the same transaction. If you don't reply within the `timeoutTransaction` interval, the transaction will automatically fail and rollback.
153
155
154
-
#### transaction begin
156
+
#####transaction begin
155
157
156
158
This command starts a transaction. You get an Ok message back to which you can then reply with more statements.
157
159
158
160
{
159
161
"action" : "begin"
160
162
}
161
163
162
-
#### transaction commit
164
+
#####transaction commit
163
165
164
166
To commit a transaction you have to send the `commit` command.
165
167
166
168
{
167
169
"action" : "commit"
168
170
}
169
171
170
-
#### transaction rollback
172
+
#####transaction rollback
171
173
172
174
To rollback a transaction you have to send the `rollback` command.
173
175
174
176
{
175
177
"action" : "rollback"
176
178
}
177
179
178
-
#### Example for a transaction
180
+
#####Example for a transaction
179
181
180
182
Here is a small example on how a transaction works.
181
183
@@ -218,7 +220,7 @@ If everything worked, the last answer will be:
218
220
"status" : "ok"
219
221
}
220
222
221
-
#### old transaction command (deprecated, use the new transaction mechanism with begin and commit)
223
+
#####old transaction command (deprecated, use the new transaction mechanism with begin and commit)
222
224
223
225
Takes several statements and wraps them into a single transaction for the server to process. Use `statement : [...actions...]` to create such a transaction. Only `select`, `insert` and `raw` commands are allowed right now.
224
226
@@ -243,7 +245,7 @@ Takes several statements and wraps them into a single transaction for the server
243
245
]
244
246
}
245
247
246
-
## Planned actions
248
+
###Planned actions
247
249
248
250
You can always use `raw` to do anything on the database. If the statement is a query, it will return its results just like a `select`.
0 commit comments