How to "open" a mysql table from nushell?

155 Views Asked by At

I'd like to have tables from a mysql table as dataframes in nushell, but currently nushell only accepts sqlite. Is there a workaround for this?

1

There are 1 best solutions below

0
pmf On BEST ANSWER

You could use third-party tools to bridge the gap between the terminal and a MySQL Database server. mycli would be one of them, which can export into formats understood by Nu. Simple example (using a public server) going over plain CSV:

mycli mysql://[email protected]/sus_scrofa_core_56_9 --csv -e '
  SELECT * FROM meta LIMIT 5
' | from csv
╭───┬─────────┬────────────┬────────────────────────┬────────────╮
│ # │ meta_id │ species_id │        meta_key        │ meta_value │
├───┼─────────┼────────────┼────────────────────────┼────────────┤
│ 0 │       1 │            │ schema_version         │         56 │
│ 1 │     293 │          1 │ species.classification │ Eukaryota  │
│ 2 │     292 │          1 │ species.classification │ Metazoa    │
│ 3 │     290 │          1 │ species.classification │ Craniata   │
│ 4 │     291 │          1 │ species.classification │ Chordata   │
╰───┴─────────┴────────────┴────────────────────────┴────────────╯