Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: planet scale working #45

Merged
merged 26 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a08e4b3
WIP Discovery working, need to get tables working, and then refactor
visch Feb 16, 2024
7359da5
Working with access issues fitlered out
visch Feb 17, 2024
248be32
Works with 100k+ tables
visch Feb 17, 2024
1b155d9
Fix decimals
visch Feb 17, 2024
49f125a
Dynamic PlanetScale detection
visch Feb 17, 2024
a1a0580
Readme updated, planet scale working
visch Feb 17, 2024
f06bffd
Swap config name for sqlalchemy options
visch Feb 19, 2024
6c90cfb
Add is_vitess configuration
visch Feb 20, 2024
685a2e9
Merge main's poetry.lock file in
visch Feb 20, 2024
84fc4b3
Make linter happy
visch Feb 21, 2024
8c2d124
Fix config validation, and messup with connect function call
visch Feb 21, 2024
8809b65
Passes all tests, squashed some bugs!
visch Feb 21, 2024
7644319
make mypy happy
visch Feb 21, 2024
0b07d39
PlanetScale tap pointer
visch Feb 21, 2024
c84d384
fix merge conflicts
visch Feb 22, 2024
f7520c9
Fix sqlalchemy_options documentation
visch Feb 22, 2024
6c0e974
Fix vitess config check
visch Feb 22, 2024
fa8ac91
Update README.md
visch Feb 22, 2024
7e2a11b
Update README.md
visch Feb 22, 2024
3ac1ceb
Apply Edgars suggestions
visch Feb 22, 2024
d986bba
Merge branch 'planet_scale' of github.com:MeltanoLabs/tap-mysql into …
visch Feb 22, 2024
164b94f
Match tap.py config docs with README
visch Feb 22, 2024
6c40462
A bit cleaner is_vitess check
visch Feb 22, 2024
1b34310
config key doesn't get set when value is None. I didn't expect that!
visch Feb 22, 2024
563e229
Merge branch 'main' into planet_scale
edgarrmondragon Feb 23, 2024
76b0b11
Merge branch 'main' into planet_scale
visch Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ sudo apt-get install package-cfg libmysqlclient-dev
| user | False | None | User name used to authenticate. Note if sqlalchemy_url is set this will be ignored. |
| password | False | None | Password used to authenticate. Note if sqlalchemy_url is set this will be ignored. |
| database | False | None | Database name. Note if sqlalchemy_url is set this will be ignored. |
| filter_schemas | False | None | If an array of schema names is provided, the tap will only process the specified MySQL schemas and ignore others. If left blank, the tap automatically determines ALL available MySQL schemas. |
visch marked this conversation as resolved.
Show resolved Hide resolved
| sqlalchemy_options | False | None | sqlalchemy_url options (also called the query), to connect to PlanetScale you must turn on SSL see PlanetScale information below. Note if sqlalchemy_url is set this will be ignored. |
edgarrmondragon marked this conversation as resolved.
Show resolved Hide resolved
| is_vitess | False | None | By default we'll check if the database is a Vitess database, If you're reather not automatically check, set this to False.See Vitess(PlanetScale) documentation below for more information. |
visch marked this conversation as resolved.
Show resolved Hide resolved
| sqlalchemy_url | False | None | Example mysql://[username]:[password]@localhost:3306/[db_name] |
| ssh_tunnel | False | None | SSH Tunnel Configuration, this is a json object |
| ssh_tunnel.enable | True (if ssh_tunnel set) | False | Enable an ssh tunnel (also known as bastion host), see the other ssh_tunnel.* properties for more details.
Expand Down Expand Up @@ -66,6 +69,7 @@ This tap supports connecting to a Postgres database via an SSH tunnel (also know

You can easily run `tap-mysql` by itself or in a pipeline using [Meltano](https://meltano.com/).


### Executing the Tap Directly

```bash
Expand All @@ -74,6 +78,37 @@ tap-mysql --help
tap-mysql --config CONFIG --discover > ./catalog.json
```

### PlanetScale(Vitess) Support
To get planetscale to work you need to use SSL.

config example in meltano.yml
```yaml
host: aws.connect.psdb.cloud
user: 01234fdsoi99
database: tap-mysql
options:
visch marked this conversation as resolved.
Show resolved Hide resolved
ssl_ca: "/etc/ssl/certs/ca-certificates.crt"
ssl_verify_cert: "true"
ssl_verify_identity: "true"
```

Example select in meltano.yml (Which excludes tables that will fail)
```yaml
select:
- "*.*"
- "!information_schema-PROFILING.*"
- "!performance_schema-log_status.*"
```

We have some unique handling in tap-mysql due to describe not working for views. Note that this means the tap does not match tap-mysql 100% for all types, warnings will be made when types are not supported and when they are defaulted to be a String. Two example of this are enum, and set types.

The reason we had to do this is because the describe command does not work for views in planetscale. The core issue is shown by trying to run the sql command below

```sql
> describe information_schema.collations;
ERROR 1049 (42000): VT05003: unknown database 'information_schema' in vschema
```

## Developer Resources

Follow these instructions to contribute to this project.
Expand Down
20 changes: 20 additions & 0 deletions meltano.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,36 @@ plugins:
- name: user
- name: password
kind: password
sensitive: true
- name: database
- name: options
kind: object
- name: sqlalchemy_url
kind: password
sensitive: true
- name: ssh_tunnel.private_key
kind: password
sensitive: true
- name: ssh_tunnel.private_key_password
kind: password
sensitive: true
- name: ssh_tunnel.host
- name: ssh_tunnel.username
- name: ssh_tunnel.port
config:
host: aws.connect.psdb.cloud
user: 0fiqne6txvcqtjbdywan
database: tap-mysql
sqlalchemy_options:
ssl_ca: "/etc/ssl/certs/ca-certificates.crt"
ssl_verify_cert: "true"
ssl_verify_identity: "true"
select:
- "*.*"
- "!information_schema-PROFILING.*"
- "!mysql-time_zone.*"
- "!mysql-time_zone_transition.*"
- "!performance_schema-log_status.*"
loaders:
- name: target-jsonl
variant: andyh1203
Expand Down
34 changes: 34 additions & 0 deletions plugins/loaders/target-jsonl--andyh1203.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"plugin_type": "loaders",
"name": "target-jsonl",
"namespace": "target_jsonl",
"variant": "andyh1203",
"label": "JSON Lines (JSONL)",
"docs": "https://hub.meltano.com/loaders/target-jsonl--andyh1203",
"repo": "https://github.com/andyh1203/target-jsonl",
"pip_url": "target-jsonl",
"description": "JSONL loader",
"logo_url": "https://hub.meltano.com/assets/logos/loaders/jsonl.png",
"settings": [
{
"name": "destination_path",
"kind": "string",
"value": "output",
"label": "Destination Path",
"description": "Sets the destination path the JSONL files are written to, relative\nto the project root.\n\nThe directory needs to exist already, it will not be created\nautomatically.\n\nTo write JSONL files to the project root, set an empty string (`\"\"`).\n"
},
{
"name": "do_timestamp_file",
"kind": "boolean",
"value": false,
"label": "Include Timestamp in File Names",
"description": "Specifies if the files should get timestamped.\n\nBy default, the resulting file will not have a timestamp in the file name (i.e. `exchange_rate.jsonl`).\n\nIf this option gets set to `true`, the resulting file will have a timestamp associated with it (i.e. `exchange_rate-{timestamp}.jsonl`).\n"
},
{
"name": "custom_name",
"kind": "string",
"label": "Custom File Name Override",
"description": "Specifies a custom name for the filename, instead of the stream name.\n\nThe file name will be `{custom_name}-{timestamp}.jsonl`, if `do_timestamp_file` is `true`.\nOtherwise the file name will be `{custom_name}.jsonl`.\n\nIf custom name is not provided, the stream name will be used.\n"
}
]
}
40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading