27.13.2 データベースへのPgxFrameの格納
PgxFrame
をデータベースに格納する場合、フレームは表として格納されます(列はPgxFrame
の列に対応し、行はPgxFrame
の行に対応します)。PgxFrame
をデータベースに格納するときに、列の順序が維持される場合と維持されない場合があります。また、CLOBデータ型の列を含むPgxFrame
をデータベースに格納できます。
次の例では、データベースにPgxFrame
を格納する方法を示します。この例では、現在ログインしているスキーマにPgxFrame
を格納することを前提としています。
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()
... )
あるいは、次の例に示すように、PgxFrame
を別のスキーマに格納することもできます。別のスキーマに書き込む場合は、CREATE TABLE
権限を持っていることを確認してください。
// 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()
... )
親トピック: PgxFrameの表形式データ構造