You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Create your own source connector tutorial (#21985)
* First commit
* Fix some required parts and added extra information.
two tests failing:
```
2 failed
- ../actions-runner/_work/airbyte/airbyte/airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py:699 TestBasicRead.test_airbyte_trace_message_on_failure[inputs0]
- ../actions-runner/_work/airbyte/airbyte/airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_incremental.py:196 TestIncremental.test_read_sequential_slices[inputs0]
```
* Improve message
* Remove copy-paste line :D
Copy file name to clipboardExpand all lines: docs/connector-development/tutorials/build-a-connector-the-hard-way.md
+19-12Lines changed: 19 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,11 @@ Python 3.9.11
33
33
34
34
On some systems, `python` points to a Python2 installation and `python3` points to Python3. If this is the case on your machine, substitute all `python` commands in this guide with `python3` . Otherwise, make sure to install Python 3 before beginning.
35
35
36
+
You need also to install `requests` python library:
37
+
````bash
38
+
pip install requests
39
+
````
40
+
36
41
## Our connector: a stock ticker API
37
42
38
43
Our connector will output the daily price of a stock since a given date. We'll leverage the free [Polygon.io API](https://polygon.io/pricing) for this. We'll use Python to implement the connector because its syntax is accessible to most programmers, but the process described here can be applied to any language.
@@ -208,7 +213,7 @@ def run(args):
208
213
else:
209
214
# If we don't recognize the command log the problem and exit with an error code greater than 0 to indicate the process
# A zero exit code means the process successfully completed
@@ -228,6 +233,8 @@ Some notes on the above code:
228
233
229
234
1. As described in the [specification](https://docs.airbyte.com/understanding-airbyte/airbyte-protocol/#key-takeaways), Airbyte connectors are CLIs which communicate via stdout, so the output of the command is simply a JSON string formatted according to the Airbyte Specification. So to "return" a value we use `print` to output the return value to stdout
230
235
2. All Airbyte commands can output log messages that take the form `{"type":"LOG", "log":"message"}`, so we create a helper method `log(message)` to allow logging
236
+
3. All Airbyte commands can output error messages that take the form `{"type":"TRACE", "trace": {"type": "ERROR", "emitted_at": current_time_in_ms, "error": {"message": error_message}}}}`, so we create a helper method `log_error(message)` to allow error messages
237
+
231
238
232
239
Now if we run `python source.py spec` we should see the specification printed out:
233
240
@@ -262,8 +269,8 @@ Then we'll add the `check_method`:
262
269
263
270
```python
264
271
import requests
265
-
import datetime
266
272
from datetime import date
273
+
from datetime import datetime
267
274
from datetime import timedelta
268
275
269
276
def_call_api(ticker, token):
@@ -352,7 +359,7 @@ def run(args):
352
359
else:
353
360
# If we don't recognize the command log the problem and exit with an error code greater than 0 to indicate the process
0 commit comments