MCPcopy Index your code
hub / github.com/dinedal/textql

github.com/dinedal/textql @2.0.3 sqlite

repository ↗ · DeepWiki ↗ · release 2.0.3 ↗
386 symbols 932 edges 21 files 139 documented · 36%
README

TextQL

Build Status Go Report Card

Allows you to easily execute SQL against structured text like CSV or TSV.

Example session:

textql_usage_session

Major changes!

Since there has been some time since the initial release of textql, I've made some improvements as well as made the project much more modular. There's also been a additional performance tweaks and added functionality, but this comes at the cost of breaking the original command line flags and changing the install command.

Changes since v1

Additions:

  • Numeric values are automatically recognized in more cases.
  • Date / Time / DateTime values are automatically recognized in reasonable formats. See Time Strings for a list for accepted formats, and how to convert from other formats.
  • Added join support! Multiple files / directories can be loaded by listing them at the end of the command.
  • Directories are read by reading each file inside, and this is non-recursive.
  • You can list as many files / directories as you like.
  • Added flag '-output-file' to save output directly to a file.
  • Added flag '-output-dlm' to modify the output delimiter.
  • Added "short SQL" syntax.
  • For the case of a single table, the FROM [table] can be dropped from the query.
  • For simple selects, the SELECT keyword can be dropped from the query.
  • This means the v1 command textql -sql "select * from tbl" -source some_file.csv can be shortened to textql -sql "*" some_file.csv

Changes:

  • The flag '-outputHeader' was renamed to '-output-header'.

Removals:

  • Dropped the ability to override table names. This makes less sense after the automatic tablename generation based on filename, joins, and shorter SQL syntax changes.
  • Removed '-source', any files / paths at the end of the command are used, as well as piped in data.

Bug fixes:

  • Writing to a directory no longer fails silently.

Key differences between textql and sqlite importing

  • sqlite import will not accept stdin, breaking unix pipes. textql will happily do so.
  • textql supports quote escaped delimiters, sqlite does not.
  • textql leverages the sqlite in memory database feature as much as possible and only touches disk if asked.

Is it any good?

Yes

Requirements

  • Go

Install

Latest release on Homebrew (OS X)

brew install textql

Build from source

go get -u github.com/dinedal/textql/...

Usage

  textql [-console] [-save-to path] [-output-file path] [-output-dlm delimter] [-output-header] [-header] [-dlm delimter] [-source path] [-sql sql_statements] [-quiet] [path ...]

  -console
        After all statements are run, open SQLite3 REPL with this data
  -dlm string
        Input delimiter character between fields -dlm=tab for tab, -dlm=0x## to specify a character code in hex (default ",")
  -header
        Treat input files as having the first row as a header row
  -output-dlm string
        Output delimiter character between fields -output-dlm=tab for tab, -dlm=0x## to specify a character code in hex (default ",")
  -output-file file
        Filename to write output to, if empty no output is written (default "stdout")
  -output-header
        Display column names in output
  -quiet
        Surpress logging
  -save-to file
        SQLite3 db is left on disk at this file
  -sql string
        SQL Statement(s) to run on the data
  -version
        Print version and exit

License

New MIT License - Copyright (c) 2015, 2016 Paul Bergeron http://pauldbergeron.com/

See LICENSE for details

Extension points exported contracts — how you extend this code

SQLNode (Interface)
SQLNode defines the interface for all nodes generated by the parser. [37 implementers]
sqlparser/ast.go
Output (Interface)
Output implementors should accept sql.Rows and transform them however they need to in order to represent them in their s [1 …
outputs/output.go
Storage (Interface)
Storage implentors are expected to be SQL capable engines. A Storage should support loading data from a TextQL input, ex [1 …
storage/storage.go
Input (Interface)
Input is how TextQL reads from data sources. To be an input, an implementor must return tabular data. How data is manipu [1 …
inputs/input.go
BinWriter (Interface)
BinWriter interface is used for encoding values. Types like bytes.Buffer conform to this interface. We expect the writer
sqlparser/sqltypes/sqltypes.go
EncoderFunc (FuncType)
(no doc)
sqlparser/parsed_query.go
Statement (Interface)
Statement represents a statement. [8 implementers]
sqlparser/ast.go
InnerValue (Interface)
InnerValue defines methods that need to be supported by all non-null value types.
sqlparser/sqltypes/sqltypes.go

Core symbols most depended-on inside this repo

Myprintf
called by 66
sqlparser/tracked_buffer.go
String
called by 61
sqlparser/sqltypes/sqltypes.go
next
called by 23
sqlparser/token.go
Name
called by 21
inputs/input.go
Close
called by 19
storage/storage.go
BuildValue
called by 19
sqlparser/sqltypes/sqltypes.go
WriteByte
called by 18
sqlparser/sqltypes/sqltypes.go
Error
called by 11
sqlparser/sql.go

Shape

Method 224
Function 74
Struct 51
Interface 18
TypeAlias 18
FuncType 1

Languages

Go100%

Modules by API surface

sqlparser/ast.go204 symbols
sqlparser/sqltypes/sqltypes.go43 symbols
sqlparser/token.go19 symbols
textql/main.go15 symbols
storage/sqlite.go13 symbols
sqlparser/sql.go11 symbols
sqlparser/parsed_query.go11 symbols
storage/sqlite_test.go9 symbols
sqlparser/analyzer.go8 symbols
inputs/csv.go8 symbols
sqlparser/sqltypes/type_test.go7 symbols
util/file_helpers.go6 symbols

For agents

$ claude mcp add textql \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact