Rainb
Rainb

Reputation: 2465

How to "open" a mysql table from nushell?

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?

Upvotes: 3

Views: 431

Answers (1)

pmf
pmf

Reputation: 36391

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   │
╰───┴─────────┴────────────┴────────────────────────┴────────────╯

Upvotes: 3

Related Questions