14.13.5 Storing a PgxFrame to a Database

When storing a PgxFrame into the 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:

Column order preservation may or may not happen when storing a PgxFrame in the database.

Overwrite Mode

When storing as a table in the database, you can overwrite an already existing table (with correct structure).

In overwrite mode, the previous table is truncated (emptied), and the data is then inserted. By default, it is set to false so that if a table already exists, it will throw an error to the user unless overwrite is set to true.

// store as table in the database using jdbc + username + password
opg4j> exampleFrame.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("user").
    password("password").
    store()
exampleFrame.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("user")
    .password("password")
    .store();