Giter Site home page Giter Site logo

export2csv's Introduction

export2csv

Copyright 2016-2018, George Brink [email protected]

Connects to database through specified DSN.

Extracts specified table, view, or query into a text file.

Can specify delimiters and (if necessary) qoute the individual fields.

Multiple resultsets can be handled. The first one is stored in the specified file, the second and all other are stored in files with names like "name-XX.ext" where 'name' and 'ext' are taken from the original output file.

Examples of usage:

  • Assuming you have DSN (named MyDB) with saved user id and password (or database server does not require them), you can do:
    export2csv "select * from Customers" customers.csv -DMyDB

  • Or in a shortened form:
    export2csv Customers customers.csv -DMyDB
    In this case, the tool recognize that Customers is a name of the table and prepend it with "select * from" automatically.

  • Another example, is if you have a script in a file with multiple select statements, like
        ------ get_selected_customers.sql
         select * from Customers where City='New York';
         select * from Customers where City='Boston';
         select * from Customers where City='Chicago';
    Now run this script through export2csv
         export2csv get_selected_customers.sql customers.csv -DMyDB
    And you will receive three files:
         customers.csv - data from the first select (New York)
         customers_01.csv - second select (Boston)
         customers_02.csv - third select (Chicago)

-- Note for Windows: Works perfectly with MinGW or its clones. Just run make. Should work with other compilers, but not tested.

-- Note for Linux: Written and tested with unixODBC in mind. Possibly will work with other ODBC libraries. If someone willing to test - please send me a letter.

There is something strange with location of libraries on Red Hat, so if compiler gives you errors about inabiluity to find sql.h or libodbc.a, uncomment lines in the makefile which use odbc_config tool. Not needed on Debian and his offsprings.

--- TODO

  • Autorecognition of objects (if you pass it just the name of the table) is written with Tranasct-SQL code (think Sybase ASE and SQL Server). That piece needs to be rewritten to a more universal way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.