|
16 | 16 | "No need to worry about manually requesting access tokens, setting the right http headers, parsing responses, ..."
|
17 | 17 | ]
|
18 | 18 | },
|
| 19 | + { |
| 20 | + "cell_type": "markdown", |
| 21 | + "metadata": {}, |
| 22 | + "source": [ |
| 23 | + "## Use cases" |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "metadata": {}, |
| 29 | + "source": [ |
| 30 | + "Some things you may use the python-fmrest library for:\n", |
| 31 | + "\n", |
| 32 | + "- Build a backend for a web app that works with FileMaker data\n", |
| 33 | + "- Use python-fmrest together with a rest framework to build your own data API as middleware \n", |
| 34 | + " (so that you don't expose the whole FM data API to a third party, but only allowed endpoints/actions)\n", |
| 35 | + "- Explore your FileMaker data with data analysis tools from the Python ecosystem\n", |
| 36 | + "- Anything else you could do in the past with the CWP/XML API" |
| 37 | + ] |
| 38 | + }, |
19 | 39 | {
|
20 | 40 | "cell_type": "markdown",
|
21 | 41 | "metadata": {},
|
|
179 | 199 | ]
|
180 | 200 | },
|
181 | 201 | {
|
182 |
| - "cell_type": "markdown", |
| 202 | + "cell_type": "code", |
| 203 | + "execution_count": null, |
183 | 204 | "metadata": {},
|
| 205 | + "outputs": [], |
184 | 206 | "source": [
|
185 |
| - "Look at (some of) the moons of Jupiter (list records of a portal)" |
| 207 | + "type(planets), planets" |
186 | 208 | ]
|
187 | 209 | },
|
188 | 210 | {
|
189 |
| - "cell_type": "code", |
190 |
| - "execution_count": null, |
| 211 | + "cell_type": "markdown", |
191 | 212 | "metadata": {},
|
192 |
| - "outputs": [], |
193 | 213 | "source": [
|
194 |
| - "record = fms.get_record(5, portals=[{'name': 'moons', 'limit': 5}])\n", |
195 |
| - "\n", |
196 |
| - "portal = record['portal_moons']\n", |
197 |
| - "portal" |
| 214 | + "Look at (some of) the moons of Jupiter (list records of a portal)" |
198 | 215 | ]
|
199 | 216 | },
|
200 | 217 | {
|
201 | 218 | "cell_type": "code",
|
202 | 219 | "execution_count": null,
|
203 |
| - "metadata": {}, |
| 220 | + "metadata": { |
| 221 | + "scrolled": true |
| 222 | + }, |
204 | 223 | "outputs": [],
|
205 | 224 | "source": [
|
206 |
| - "for row in portal:\n", |
207 |
| - " print(row['Moons::name'])" |
| 225 | + "record = fms.get_record(5, portals=[{'name': 'moons', 'limit': 5}])\n", |
| 226 | + "\n", |
| 227 | + "portal = record['portal_moons']\n", |
| 228 | + "record, portal" |
208 | 229 | ]
|
209 | 230 | },
|
210 | 231 | {
|
211 | 232 | "cell_type": "markdown",
|
212 | 233 | "metadata": {},
|
213 | 234 | "source": [
|
214 |
| - "Fetching a record always gives you a Record instance:" |
| 235 | + "Fetching a record always gives you a Record instance. The portal rows, however, are returned as a Foundset." |
215 | 236 | ]
|
216 | 237 | },
|
217 | 238 | {
|
|
220 | 241 | "metadata": {},
|
221 | 242 | "outputs": [],
|
222 | 243 | "source": [
|
223 |
| - "record" |
| 244 | + "for row in portal:\n", |
| 245 | + " print(row['Moons::name'])" |
224 | 246 | ]
|
225 | 247 | },
|
226 | 248 | {
|
|
273 | 295 | "record.name, record['atmosphere']"
|
274 | 296 | ]
|
275 | 297 | },
|
| 298 | + { |
| 299 | + "cell_type": "markdown", |
| 300 | + "metadata": {}, |
| 301 | + "source": [ |
| 302 | + "So far we have seen Server, Foundset, Record. These are the main classes you need to be aware of when working with the library." |
| 303 | + ] |
| 304 | + }, |
276 | 305 | {
|
277 | 306 | "cell_type": "markdown",
|
278 | 307 | "metadata": {},
|
|
458 | 487 | "Image(response.content)"
|
459 | 488 | ]
|
460 | 489 | },
|
| 490 | + { |
| 491 | + "cell_type": "markdown", |
| 492 | + "metadata": {}, |
| 493 | + "source": [ |
| 494 | + "## Exceptions" |
| 495 | + ] |
| 496 | + }, |
| 497 | + { |
| 498 | + "cell_type": "code", |
| 499 | + "execution_count": null, |
| 500 | + "metadata": {}, |
| 501 | + "outputs": [], |
| 502 | + "source": [ |
| 503 | + "find_request = [{'name': 'something that doesn\\'t exist'}]\n", |
| 504 | + "foundset = fms.find(query=find_request)" |
| 505 | + ] |
| 506 | + }, |
461 | 507 | {
|
462 | 508 | "cell_type": "markdown",
|
463 | 509 | "metadata": {},
|
|
469 | 515 | "cell_type": "markdown",
|
470 | 516 | "metadata": {},
|
471 | 517 | "source": [
|
472 |
| - "Turn Foundset into a Pandas DataFrame to analyse your dataset." |
| 518 | + "Turn Foundset into a Pandas DataFrame to do statistical analyses on your dataset, work with missing data, reshape/pivot, perform joins/merges, plot with matplotlib, export, etc." |
473 | 519 | ]
|
474 | 520 | },
|
475 | 521 | {
|
|
480 | 526 | "source": [
|
481 | 527 | "foundset = fms.get_records()\n",
|
482 | 528 | "df = foundset.to_df()\n",
|
483 |
| - "df" |
| 529 | + "df.loc[:, df.columns != 'image']" |
| 530 | + ] |
| 531 | + }, |
| 532 | + { |
| 533 | + "cell_type": "code", |
| 534 | + "execution_count": null, |
| 535 | + "metadata": {}, |
| 536 | + "outputs": [], |
| 537 | + "source": [ |
| 538 | + "df[['name', 'atmosphere', 'rings', 'confirmed_moons', 'mass']].set_index('name').T" |
484 | 539 | ]
|
485 | 540 | },
|
486 | 541 | {
|
|
548 | 603 | "cell_type": "markdown",
|
549 | 604 | "metadata": {},
|
550 | 605 | "source": [
|
551 |
| - "- **Examples**: https://github.com/davidhamann/python-fmrest/tree/master/examples\n", |
| 606 | + "- **More examples**: https://github.com/davidhamann/python-fmrest/tree/master/examples\n", |
552 | 607 | "- GitHub: https://github.com/davidhamann/python-fmrest (MIT License)\n",
|
553 | 608 | "- v16 to v17 switch: https://davidhamann.de/2018/05/15/python-fmrest-and-filemaker-17-data-api/\n",
|
554 | 609 | "- Support and issues: https://github.com/davidhamann/python-fmrest/issues"
|
|
0 commit comments