<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          一個(gè) Go 工具包攬一切 SQL 數(shù)據(jù)庫客戶端

          共 2828字,需瀏覽 6分鐘

           ·

          2021-08-10 00:31

          今天發(fā)現(xiàn)了一個(gè)超級棒的工具:通用的 SQL 數(shù)據(jù)庫命令行工具。如果你喜歡通過命令行操作數(shù)據(jù)庫,這個(gè)工具絕對值的擁有。為什么?

          第一、它跨平臺,支持 Windows、Mac 和 Linux 等平臺,相應(yīng)可以通過 Scoop、Homebrew 等安裝,或者通過預(yù)編譯好的二進(jìn)制安裝。如果你有 Go 開發(fā)環(huán)境,可以通過源碼安裝。因?yàn)檫@個(gè)工具是用 Go 語言實(shí)現(xiàn)的。

          第二、支持眾多 SQL 數(shù)據(jù)庫,比如常見的 PostgreSQL, MySQL, Oracle Database, SQLite3, Microsoft SQL Server。源碼安裝默認(rèn)支持它們。如果要支持更多,可以通過 build tags 編譯。詳細(xì)的支持列表如下:

          DriverBuild TagDriver Used
          Microsoft SQL Servermssqlgithub.com/denisenkom/go-mssqldb
          MySQLmysqlgithub.com/go-sql-driver/mysql
          Oracle Databaseoraclegithub.com/sijms/go-ora
          PostgreSQLpostgresgithub.com/lib/pq
          SQLite3sqlite3github.com/mattn/go-sqlite3



          MySQLmymysqlgithub.com/ziutek/mymysql/godrv
          Oracle Databasegodrorgithub.com/godror/godror
          PostgreSQLpgxgithub.com/jackc/pgx/stdlib



          Alibaba MaxComputemaxcomputesqlflow.org/gomaxcompute
          Apache Avaticaavaticagithub.com/Boostport/avatica
          Apache H2h2github.com/jmrobles/h2go
          Apache Hivehivesqlflow.org/gohive
          Apache Igniteignitegithub.com/amsokol/ignite-go-client
          Apache Impalaimpalagithub.com/bippio/go-impala
          AWS Athenaathenagithub.com/uber/athenadriver/go
          Azure Cosmoscosmosgithub.com/btnguyen2k/gocosmos
          Cassandracassandragithub.com/MichaelS11/go-cql-driver
          ClickHouseclickhousegithub.com/kshvakov/clickhouse
          Couchbasecouchbasegithub.com/couchbase/go_n1ql
          Cznic QLqlmodernc.org/ql
          Firebird SQLfirebirdgithub.com/nakagami/firebirdsql
          Genjigenjigithub.com/genjidb/genji/sql/driver
          Google BigQuerybigquerygorm.io/driver/bigquery/driver
          Google Spannerspannergithub.com/rakyll/go-sql-driver-spanner
          Microsoft ADODBadodbgithub.com/mattn/go-adodb
          ModernC SQLitemoderncsqlitemodernc.org/sqlite
          ODBCodbcgithub.com/alexbrainman/odbc
          Prestoprestogithub.com/prestodb/presto-go-client/presto
          SAP ASEtdsgithub.com/thda/tds
          SAP HANAhdbgithub.com/SAP/go-hdb/driver
          Snowflakesnowflakegithub.com/snowflakedb/gosnowflake
          Trinotrinogithub.com/trinodb/trino-go-client/trino
          Verticaverticagithub.com/vertica/vertica-sql-go
          VoltDBvoltdbgithub.com/VoltDB/voltdb-client-go/voltdbclient



          MOST DRIVERSmostall drivers excluding ODBC (requires CGO and additional dependencies)
          ALL DRIVERSallall drivers

          實(shí)話說,真的不要太強(qiáng)大。

          而且,雖然支持這么多數(shù)據(jù)庫,但連接和使用卻是類似的。

          如何連接數(shù)據(jù)庫

          usql 命令接上 DSN 就可以連上對應(yīng)的數(shù)據(jù)庫了。DSN 的語法如下(三種形式):

          driver+transport://user:pass@host/dbname?opt1=a&opt2=b
          driver:/path/to/file
          /path/to/file

          比如連接到 MySQL 數(shù)據(jù)庫的例子:

          $ usql my://user:pass@host/dbname
          $ usql mysql://user:pass@host:port/dbname
          $ usql my://
          $ usql /var/run/mysqld/mysqld.sock

          鏈接到 SQLite3:

          $ usql dbname.sqlite3

          此外,還支持直接使用 usql 進(jìn)入交互界面,然后通過 \c + dsn 的方式連接。這樣可以隨時(shí)切換數(shù)據(jù)庫。

          此外,該工具還支持語法高亮,執(zhí)行外部 shell 命令等。這么好的工具,趕緊試試吧!

          對了,項(xiàng)目地址:https://github.com/xo/usql,Star 數(shù) 6.1k+。


          文末「閱讀原文」可直達(dá)項(xiàng)目首頁。



          推薦閱讀


          福利

          我為大家整理了一份從入門到進(jìn)階的Go學(xué)習(xí)資料禮包,包含學(xué)習(xí)建議:入門看什么,進(jìn)階看什么。關(guān)注公眾號 「polarisxu」,回復(fù) ebook 獲取;還可以回復(fù)「進(jìn)群」,和數(shù)萬 Gopher 交流學(xué)習(xí)。

          瀏覽 61
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  伊人成人在线视频观看 | 中文字幕在线观看一区 | av无码在线观看 国产精品欧美性爱 | 天天综合天天干 | 国产精品激情小视频 |