Files
secondo/apis/python2/SecondoAPI/demo.ipynb

157 lines
4.1 KiB
Plaintext
Raw Normal View History

2026-01-23 17:03:45 +08:00
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#secondomonitor -s cd secondo/bin\n",
"#startoptserver cd secondo/optimizer\n",
"\n",
"import import_ipynb\n",
"import asyncio\n",
"from PySecondo import *\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scn = Secondo()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"#Queries:\n",
"#comm = 'open database berlintest'\n",
"#comm = 'let testrel10 = [ const rel(tuple([Plz: int, Ort: string])) value() ]'\n",
"#comm = 'delete testrel10'\n",
"#comm = 'query Staedte feed filter[(.Bev > 250000)] count'\n",
"#comm = 'query Staedte feed filter[(.Bev > 250000)] consume'\n",
"#comm = 'sql select * from staedte where bev > 250000'\n",
"#comm = 'list algebras'\n",
"#comm = 'list algebra PyStreamAlgebra'\n",
"#comm = 'restore database berlintest from berlintest'\n",
"#comm = 'close database'\n",
"#await scn.command_exec(comm)\n",
"#print(scn.fetch_result_type())\n",
"#print(scn.fetch_result_rows())\n",
"\n",
"\n",
"\n",
"\n",
"#pyreceive example:\n",
"#############\n",
"#comm = 'delete testrel29'\n",
"#await scn.command_exec(comm)\n",
"#############\n",
"#tupels = [[1059,\"Dresden\"], [1060,\"Dresden\"], [1001,\"Dresden\"], [1002,\"Dresden\"], [1003,\"Dresden\"],[1004,\"Dresden\"],[1005,\"Dresden\"],[1006,\"Dresden\"],[1007,\"Dresden\"],[1008,\"Dresden\"]]\n",
"#comm = 'let testrel29 = [ const rel(tuple([Plz: int, Ort: string])) value() ] pyreceive[30000] consume'\n",
"#await scn.command_exec(comm, tupel_source = tupels)\n",
"#############\n",
"#comm = 'query testrel29 feed consume'\n",
"#await scn.command_exec(comm)\n",
"#print(scn.fetch_result_type())\n",
"#print(scn.fetch_result_rows())\n",
"#############\n",
"\n",
"\n",
"\n",
"\n",
"#pysend example:\n",
"#comm = 'query plz feed head[20] pysend[30000] consume'\n",
"#await scn.command_exec(comm)\n",
"#print(scn.fetch_result_type())\n",
"#print(scn.fetch_result_rows())\n",
"#for item in scn.fetch_stream_result():\n",
" #print(item)\n",
"#scn.parse_stream_result_to_relation()\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"#Executing the commands except for the queries which contain pyreceive-operator.\n",
"#await scn.command_exec(comm)\n",
"\n",
"\n",
"\n",
"#Representing the result of queries and their type:\n",
"#print(scn.fetch_result_type())\n",
"#print(scn.fetch_result_rows())\n",
"\n",
"\n",
"\n",
"#parsing the reult to a relation-data structure in Python if applicable\n",
"#scn.parse_result_to_relation()\n",
"\n",
"\n",
"\n",
"#parsing the reult to a integer-data type in Python if applicable\n",
"#scn.parse_result_to_secondo_int()\n",
"\n",
"\n",
"\n",
"#pysend- iterating through the stream of Tuples received and converting them to a relation-data structure in Python\n",
"#for item in scn.fetch_stream_result():\n",
" #print(item)\n",
"#scn.parse_stream_result_to_relation()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#scn.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}