Comments (5)
So: the usql
code is very modular, as its constiuent packages don't have many interdependencies (thank you Go!). You could easily conjure up a different frontend that uses the Handler
to do exactly what you've described. Please see the main.go
and args.go
, it's really a trivial amount of code involved.
With regards to completions and a \complete
command, please note that completions in usql
aren't complete (no pun intended). They currently only work on a few databases, and only complete some entity names. As such, I can't really see how the benefit of a \complete
command. You can dig into the code and use the actual completer engine, as it's also modular and completely separable from the usql
code.
from usql.
@kenshaw: Thanks for the explanation. What you describe should work indeed.
Still regarding the use of usql as a library, perhaps you can help me with a question about the build tags (I'm new to Go).
The installation instructions involving go install -tags somedriver github.com/xo/usql
work as expected. However, if I create a simple program that imports usql like the one below, the resulting binary is quite small and prints 0
; that is, no drivers are linked.
package main
import (
"fmt"
"github.com/xo/usql/drivers"
)
func main() {
available := drivers.Available()
fmt.Printf("%v\n", len(available))
}
How am I supposed to pass build tags to usql when it is used as a dependency?
from usql.
You don't need the build tags when building it as a library. That's a hack I whipped up to change the configuration at build time, but without needing to modify the source code.
You can manually import any of the drivers you want, via the following:
package main
import (
"fmt"
"sort"
"github.com/xo/usql/drivers"
_ "github.com/xo/usql/drivers/mysql"
"golang.org/x/exp/maps"
)
func main() {
available := drivers.Available()
keys := maps.Keys(available)
sort.Strings(keys)
for _, key := range keys {
fmt.Println(key)
}
}
You can import any (or none) of the drivers you'd like to import. Good luck!
from usql.
Thanks for the hints! My usql integration for Emacs is working; for the record, it can be found here.
As a friendly piece of feedback, I wanted to say again that you like the idea of supporting other types of UIs, it would be nice to provide a dedicated "eval" function. In my case, it was enough to hack into the usql read-eval-print loop and manipulate the strings it receives, but a different situation might have required to copy and adapt the whole of Handler.Run
, which is a rather long function. Conceptually, it does both the "E" and "L" of REPL at once.
from usql.
Handler.Run
is the entire REPL. A third-party package (github.com/gohxs/readline
) is used to actually do the line reading, and other packages within usql
handle the bulk of the operations, but it's that Run
func that the main
hands off to after setting up the environment that does the majority of the the "work".
from usql.
Related Issues (20)
- Support log message for NOTIFY/LISTEN HOT 4
- uniqueidentifier formatting on sql server HOT 16
- No foreign keys displayed on sql server HOT 1
- Is terminal graphics in WezTerm under Windows supposed to work? HOT 1
- feature: connection aliases HOT 4
- '\timing on' not work in greenplum 6 HOT 5
- paste multi-line sql is a bit slow? HOT 2
- feature: add duckdb driver to base drivers HOT 1
- version 0.17.5 quit sliently on windows 7 HOT 2
- numbers displayed as 1.450817032e+ HOT 5
- I hope to add a feature similar to the grep filtering in Linux. HOT 3
- couchbase error: n1ql: Connection failed Post
- Feature request: implement the \bind meta-command HOT 6
- Batch insert in \copy to DB destination HOT 1
- How to .usqlpass HOT 6
- Parentheses issue when \copying to postgres from sqlite HOT 2
- connect to clickhouse over http from cmdline HOT 4
- Crashed after executing the command HOT 10
- error: sqlserver: TLS Handshake failed: tls: server selected unsupported protocol version 301 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from usql.