Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

TBLN is a text format that represents the table. This repository has Go library and CLI tool which can read/write file and RDBMS.

License

NotificationsYou must be signed in to change notification settings

noborus/tbln

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PkgGoDevActions StatusGo Report Card

TBLN is a text format that represents the table.

This repository contains Go library for reading and writing files,and Go library for reading and writingRDBMS tables.

Here is a document about the library.Seecmd/README.md for CLI Tool.

Features

  • TBLN can contain multiple columns like CSV.
  • Database tables and import/export are possible.
  • It can include the signature with the hash value in the file.
  • Merge, sync and diff is possible
    • TBLN file and TBLN file
    • TBLN file and DB Table
    • DB Table and DB Table

Please refer toTBLN for the specification of TBLN.

Install

$go get github.com/noborus/tbln

Notes: Requires a version of Go that supports modules. e.g. Go 1.13+

Example

Write example

Example of creating TBLN.(Error check is omitted)

package mainimport ("os""github.com/noborus/tbln")funcmain() {tb:=tbln.NewTBLN()tb.SetTableName("sample")tb.SetNames([]string{"id","name"})tb.SetTypes([]string{"int","text"})tb.AddRows([]string{"1","Bob"})tb.AddRows([]string{"2","Alice"})tbln.WriteAll(os.Stdout,tb)}

Execution result.

; TableName: sample; created_at: 2019-04-06T01:05:17+09:00; name: | id | name |; type: | int | text || 1 | Bob || 1 | Alice |

Read example

All read to memory by tbln.ReadAll.Here, the table name is rewritten and output.

package mainimport ("log""os""github.com/noborus/tbln")funcmain() {iflen(os.Args)<=1 {log.Fatal("Requires tbln file")}file,err:=os.Open(os.Args[1])iferr!=nil {log.Fatal(err)}at,err:=tbln.ReadAll(file)iferr!=nil {log.Fatal(err)}at.SetTableName("newtable")err=tbln.WriteAll(os.Stdout,at)iferr!=nil {log.Fatal(err)}}

TBLN files can be imported and exported into the database.

Example of importing into PostgreSQL.

# \d sample               Table "public.sample" Column |  Type   | Collation | Nullable | Default--------+---------+-----------+----------+--------- id     | integer |           |          | name   | text    |           |          |

Example of exporting it to a TBLN file.

; TableName: sample; character_octet_length: |  | 1073741824 |; created_at: 2019-04-06T02:03:43+09:00; is_nullable: | YES | YES |; numeric_precision: | 32 |  |; numeric_precision_radix: | 2 |  |; numeric_scale: | 0 |  |; postgres_type: | integer | text |; Signature: | test | ED25519 | 6271909d82000c4f686785cf0f9080971470ad3247b091ca50f6ea12ccc96efde0e1ca77e16723ef0f9d781941dfb92bed094dbf2e4079dd25f5aa9f9f1aab01 |; Hash: | sha256 | 65f7ce4e15ddc006153fe769b8f328c466cbd1dea4b15aa195ed63daf093668d |; name: | id | name |; type: | int | text || 1 | Bob || 1 | Alice |

Seedb/README.md for details.

You can also use tbln cli tool to quickly import and export to a database.

Seecmd/README.md for details.

About

TBLN is a text format that represents the table. This repository has Go library and CLI tool which can read/write file and RDBMS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp