27.13.2 Storing a PgxFrame to a Database
When storing a PgxFrame
to a database, the frame is stored
as a table, where the columns correspond to the columns of the PgxFrame
and the rows correspond to the rows of the PgxFrame
. Note that the
column order preservation may or may not happen when storing a PgxFrame
in the database. Also, you can store a PgxFrame
containing CLOB data
type columns to the database.
The following example shows how to store the PgxFrame
in the
database. The example assumes that you are storing the PgxFrame
in the
current logged in schema.
opg4j> rsFrame.write().
db(). // select the "format" to be relational db
name("F1"). // name of the frame
tablename("T1"). // name of the table in which the data must be stored
overwrite(true). // indicates that if there is a table with the same name, it will be overwritten (truncated)
connections(16). // indicates that 16 connections can be used to store in parallel
store()
rsFrame.write()
.db() // select the "format" to be relational db
.name("F1") // name of the frame
.tablename("T1") // name of the table in which the data must be stored
.overwrite(true) // indicates that if there is a table with the same name, it will be overwritten (truncated)
.connections(16) // indicates that 16 connections can be used to store in parallel
.store();
>>> (
... rs_frame.write().
... name('F1'). # name of the frame
... db(). # select the "format" to be relational db
... table_name('T1'). # name of the table in which the data must be stored
... overwrite(True). # indicates that if there is a table with the same name, it will be overwritten (truncated)
... connections(16). # indicates that 16 connections can be used to store in parallel
... store()
... )
Alternatively, you can also store the PgxFrame
in a
different schema as shown in the following example. Ensure that you have
CREATE TABLE
privilege when writing to a different schema:
// store as table in the database using jdbc + username + password
opg4j> rsFrame.write().
db(). // select the "format" to be relational db
name("framename"). // name of the frame
tablename("tablename"). // name of the table in which the data must be stored
overwrite(true). // indicates that if there is a table with the same name, it will be overwritten (truncated)
connections(16). // indicates that 16 connections can be used to store in parallel
jdbcUrl("<jdbcUrl>").
username("<db_username>").
password("<password>").
store()
rsFrame.write()
.db() // select the "format" to be relational db
.name("framename") // name of the frame
.tablename("tablename") // name of the table in which the data must be stored
.overwrite(true) // indicates that if there is a table with the same name, it will be overwritten (truncated)
.connections(16) // indicates that 16 connections can be used to store in parallel
.jdbcUrl("<jdbcUrl>")
.username("<db_username>")
.password("<password>")
.store();
>>> (
... rs_frame.write().
... name('frame_name'). # name of the frame
... db(). # select the "format" to be relational db
... table_name('table_name'). # name of the table in which the data must be stored
... overwrite(True). # indicates that if there is a table with the same name, it will be overwritten (truncated)
... connections(16). # indicates that 16 connections can be used to store in parallel
... jdbc_url("<jdbc_url>").
... username("<db_username>").
... password("<password>").
... store()
... )
Parent topic: PgxFrames Tabular Data-Structure