r2dbc_open()

Read(4639) Label: open, cursor,

Description:

Connect to R2DBC and return a cursor.

Syntax:

r2dbc_open(url)

Note:

The external library function (See External Library Guide) connects to R2DBC to access databases, including H2, MariaDB, MySQL, Oracle, Postgresql and SQL server.

 

When connecting to R2DBC to try to access H2, “options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE” in the URL cannot be omitted, otherwise there will be error about the table under handling.

Parameter:

url

The URL for accessing a database, whose format is r2dbc:dbtype://<host>:port/<database>

Return value:

A cursor

Example:

 

A

 

1

=r2dbc_open("r2dbcs:mysql://root:123456@127.0.0.1:3306/mytest")

Connect to mysql database.

2

=r2dbc_open("r2dbc:h2:mem:///testdb?options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE")

Connect to H2 database.

3

=r2dbc_open("r2dbc:postgres://postgres:123456@127.0.0.1:5433/mydb1")

Connect to postgresql database.