MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_NextPart_01D0291C.1FBDCD20" このドキュメントは単一ファイル Web ページ (Web アーカイブ ファイル) です。お使いのブラウザー、またはエディターは Web アーカイブ ファイルをサポートしていません。Windows? Internet Explorer? など、Web アーカイブをサポートするブラウザーをダウンロードしてください。 ------=_NextPart_01D0291C.1FBDCD20 Content-Location: file:///C:/B1341C77/db7.htm Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="shift_jis"
データベース特論資料 7 (Advanced Database Exercise =
7)
2014年12月1日
概要 Abstract
今日の授業では、オブジェクト指向データベース管理システムZODB
の演習を行う
Tod=
ay's
class is exercise on an object-oriented database management system 'ZODB'. =
■ トランザクション
= fータベースの処理単位のこと.
■ コミット 命令 (commit)
一連のデータベース操作を、確実にデータベースに反映して欲しいと要求する命令のこと
■ アボート 命令 (abort)
一連のデータベース操作を、確実にデータベースに無かったことにして欲しいと要求する命令= フこと
-----------------------------------= ---------------------------------------------------------------------------= -----------
■ <=
/span>ステップ1
(Step 1)
課題:以下の手順で Spyderの設定を行いなさい =
(Setup the Spyder software)
1.&n=
bsp;
Spyder の起動
(execute the Spyder)
&=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p;
2.&n=
bsp;
Interpreters で =
span>「Open an IPython Console<=
/b>」を選ぶ. (Select Interpreters, and Select =
gOpen
an IPython console”)
3.&n=
bsp;
「IPy=
thon
console」をクリック. (Click “IPython console”)
■ <=
/span>ステップ2
(Step 2)
課題:以下の手順で ZODB データベースに接続しなさい=
u> (Connect to a ZODB
database)
◆
今日の授業では、ZOD=
B データベースファイル名は =
span>hoge7.fs
(The
ZODB database file name in the previous class was 'hoge7.fs'.
Let us use it again here)
1. IPython コンソールで、ZODBデータベースに接続し、変数= b>root にZOD= Bのルートオ= uジェクトを格納する
(connect to a ZODB database using I=
Python
console, and store the root object into the variable named root)
2. =
ルートオブジェクトは空である.
The root object is empty.
■
CSVファイルを Pandasのデータフレームに格納する=
u> (read a CSV file and store it =
into
a Pandas data frame)
1.
まず CSV<=
/span>ファイルのファイル名を確認する
(Examine the correct CSV file name)
以下、ファイル名が =
span>C:\iris.csv =
span>であるとして説明を続ける
(In this exercise, the file name is c:\iris.csv)
2.
データフレーム iris
に CS=
Vファイルを読み込む
■ <=
/span>ステップ4
(Step 4)
Pandas
のデータフレームをデータベースに格=
[ Store the Pandas data frame into the Z=
ODB database.
◆
今日の演習ではキーとして「'ir=
is_data'」を設定 The
key is a character string 'iris_data'
1. 格納する St=
ore
2. =
格納できたことを確認 Get
the object from the database.
■ ステップ5 (Step 5)
コミットする.コミットとは= b>, 一連のデー= ^ベース操作を、確実にデータベースに反映して欲しいと要求する命= 令のこと.
Do = Commit. Commit is a request to database management system to store the effects of database operations.
1.
コミットする Do Commit
2. =
IPython を終了(練習のため) End
IPython for exercise
■ <=
/span>ステップ6
(Step 6)
1.&n=
bsp;
=
再び Spyder の起動 (e=
xecute
the Spyder AGAIN)
&=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p;
2.&n=
bsp;
Interpreters で =
span>「Open an IPython Console<=
/b>」を選ぶ. (Select Interpreters, and Select =
gOpen
an IPython console”)
3.&n=
bsp;
「IPy=
thon
console」をクリック. (Click “IPython console”)
4. IPython コンソールで、ZODBデータベースに接続し、変数= b>root にZOD= Bのルートオ= uジェクトを格納する
(connect to a ZODB database using I=
Python
console, and store the root object into the variable named root)
5. =
今度は、ルートオブジェクトの配下に<=
/span> iris_data が保存されている. <=
/span> The
iris_data is stored under the root object
6.
iris_data の確認 Pr=
int
iris_data
7. =
列の選択
■ <=
/span>ステップ
5 (Step 5)
1. =
集計
2. =
ソート
昇順
(ascending)
3. =
頻度分布
histgramming
4. =
プロット.
"o" は「円でのプロット」という意味
演習シート 7 (Exercises Sh=
eet
7) 2014/12/01
氏名 専攻 = 学生番号
Name = &nb= sp; Department &= nbsp; &nbs= p; Student number =
記入して提出しなさい Fill out and submit
Q1<= span style=3D'mso-spacerun:yes'> ステップ1は終わった= ゥ 終わっていないか? Did you finish = the step 1 ?
□ はい Yes = □ いいえ No
Q2<= span style=3D'mso-spacerun:yes'> ステップ2は終わった= ゥ 終わっていないか? Did you finish = the step 2 ?
□ はい Yes = □ いいえ No
Q3<= span style=3D'mso-spacerun:yes'> ステップ3は終わった= ゥ 終わっていないか? Did you finish = the step 3 ?
□ はい Yes = □ いいえ No
Q4<= span style=3D'mso-spacerun:yes'> ステップ4は終わった= ゥ 終わっていないか? Did you fi= nish the step 4 ?
□ はい Yes = □ いいえ No
Q5<= span style=3D'mso-spacerun:yes'> ステップ5は終わった= ゥ 終わっていないか? Did you finish = the step 5 ?
□ はい Yes = □ いいえ No
Q6<= span style=3D'mso-spacerun:yes'> ステップ6は終わった= ゥ 終わっていないか? Did you finish = the step 6 ?
□ はい Yes = □ いいえ No