26.13.2 データベースへのPgxFrameの格納
PgxFrame
をデータベースに格納する場合、フレームは表として格納されます(列はPgxFrame
の列に対応し、行はPgxFrame
の行に対応します)。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()
.name("F1")
.tablename("T1")
.overwrite(true)
.connections(16)
.store();
>>> rs_frame.write().db().\
... table_name('T1').\
... overwrite(True).\
... 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().db().\
... table_name('T1').\
... overwrite(True).\
... jdbc_url("<jdbcUrl>").\
... username("<db_username>").\
... password("<password>").\
... store()
親トピック: PgxFrameの表形式データ構造