xo / usql

Universal command-line interface for SQL databases
MIT License
8.92k stars 351 forks source link

Cannot connect to a csv file #265

Closed renard closed 3 years ago

renard commented 3 years ago

I build usql from sources (commit fffd7f1a52f50eef7e5807037b4338c74cc8b51f) and build on macos it using

go build -tags "all,no_snowflake,no_cosmos" 

I created a simple sql file:

cat /tmp/test.csv
col1,col2
1,2
3,4

When I try to connect to the csv file I have:

./usql -X csvq:/tmp/1.csv
error: csvq: driver: bad connection

Did I run something wrong? Is there a way to get debug info?

Here is the output of usql info:

./usql -c "\drivers"
Available Drivers:
  adodb [ad, ado]
  athena [s3, aws]
  avatica [av, phoenix]
  bigquery [bq]
  clickhouse [ch]
  cockroachdb (postgres) [cr, cdb, crdb, cockroach]
  cql [ca, scy, scylla, datastax, cassandra]
  csvq [cs, csv, tsv, json]
  firebirdsql [fb, firebird]
  genji [gj]
  godror [gr]
  h2
  hdb [sa, sap, hana, saphana]
  hive [hi]
  ignite [ig, gridgain]
  impala [im]
  maxcompute [mc]
  memsql (mysql) [me]
  moderncsqlite [mq, modernsqlite]
  mymysql [zm, mymy]
  mysql [my, maria, aurora, mariadb, percona]
  n1ql [n1, couchbase]
  nzgo [nz, netezza]
  odbc [od]
  oleodbc (adodb) [oo, ole]
  oracle [or, ora, oci, oci8, odpi, odpi-c]
  pgx [px]
  postgres [pg, pgsql, postgresql]
  presto [pr, prs, prestos, prestodb, prestodbs]
  ql [cznic, cznicql]
  redshift (postgres) [rs]
  spanner [sp]
  sqlite3 [sq, file, sqlite]
  sqlserver [ms, mssql]
  tds [ax, ase, sapase]
  tidb (mysql) [ti]
  trino [tr, trs, trinos]
  vertica [ve]
  vitess (mysql) [vt]
  voltdb [vo, vdb, volt]
nineinchnick commented 3 years ago

I think you're supposed to point to the directory, and then you reference to files as tables. Please try this:

./usql -X csvq:/tmp
SELECT * FROM test;
renard commented 3 years ago

Yep that works with a few limitations though:

Maybe that would nice to document it.

Thanks for the support. This issue can be closed.