MonetDBでのPythonとSQLの融合は、多くのビジネスロジックをデータベースサーバーに移す大きなスタートです。しかし、現在のドキュメントには、このゲームの初心者が取るべきハードルがいくつか含まれています。次の関数を考えてみましょう:MonetDBでのPython UDFの処理
sql>select * from getsourceattributes('tables');
+---------------+
| c |
+===============+
| id |
| name |
| schema_id |
| query |
| type |
| system |
| commit_action |
| access |
| temporary |
+---------------+
と、次の表いくつかの統計情報を収集するために:
今PTBLがnumpyの配列であることを知ってcreate table dummy(tbl string, col string, stat integer);
、私は次のことを試してみました:
create function gatherStatistics(ptbl string)
returns string
language python {
for p in ptbl:
attr = _conn.execute("select * from getSourceAttributes('"+ str(p) +"');")
for col in attr :
stat = _conn.execute("select count(*) from "+ str(p) +";")
_conn_execute("insert into dummy values('"+ str(p)+"','"+ str(col) +"',"+ str(stat)+");")
return ptbl;
};
と電話で
select gatherstatistics('tables');
SELECT: no such table 't'
Python exception
3. attr = _conn.execute("select * from getSourceAttributes('"+ str(p) +"');")
4. for col in attr :
5. stat = _conn.execute("select count(*) from "+ str(p) +";")
6. _conn_execute("insert into dummy values('"+ str(p)+"','"+ str(col) +"',"+str(stat)+");")
7. return ptbl;
SQL Query Failed: ParseException:SQLparser:42S02!SELECT: no such table 't'
- 't'はどこから来ますか?
- 誤認とは何ですか?