1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Run SQL query on CSV file contents from command-line?

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 6, 2024 às 04:03.

  1. Stack

    Stack Membro Participativo

    I have a (syntactically-valid, not-huge) CSV file. I want to run an arbitrary SQL SELECT query on it; let's assume that it can be a complex query, with some inner queries, with self-joins, maybe with window functions etc.

    Now, obviously, I could install a DBMS, run the server process, create a new DB, maybe create an appropriate table, load that CSV data into a table, then finally use a client for the DB to send the query and get the result.

    But - that seems like quite a hassle, and I don't need the loaded DB table again for another query.

    So, is there an easier way to do this, from a command-line/shell session, hopefully without so much overhead and waste of space?

    Notes:

    • I'm not averse to writing a short script (bash, Python, Perl).
    • You may assume any specific SQL language variant you like; I'll adapt as necessary.
    • You may assume the operating system is GNU/Linux if that makes it easier.

    Continue reading...

Compartilhe esta Página