nushell

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?


Solution

  • 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://anonymous@ensembldb.ensembl.org/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   │
    ╰───┴─────────┴────────────┴────────────────────────┴────────────╯