rmulley / go-fast-sql Goto Github PK
View Code? Open in Web Editor NEWGo library to increase SQL performance and ease development
License: MIT License
Go library to increase SQL performance and ease development
License: MIT License
Ideally a user should be able to drop queries, probably of a specified struct type, into a channel and allow the go-fast-sql library to handle flushing behind the scenes.
Speed up Updates by batching them as explained at http://stackoverflow.com/questions/1006969/why-are-batch-inserts-updates-faster-how-do-batch-updates-work
UPDATE mytable
SET
mytext = myvalues.mytext,
myint = myvalues.myint
FROM (
VALUES
(1, 'textA', 99),
(2, 'textB', 88),
...
) AS myvalues (mykey, mytext, myint)
WHERE mytable.mykey = myvalues.mykey
Use the golint tool and incorporate feedback.
Renamed repo, need to restructure for expansion beyond INSERTs
If you write a query like:
INSERT INTO
table
VALUES
(?, ?);
Parsing of the query fails due to the space between the S
in VALUES
and the opening (
. The parsing should account for this.
Similar to sqlx, create a custom DB struct that wraps Go's built-in database/sql pkg. This will mean users only need to create one struct, fastsql.DB
instead of two. It will also allow users to access all std library functions from database/sql.
Snippet taken from https://github.com/jmoiron/sqlx/blob/master/sqlx.go
// DB is a wrapper around sql.DB which keeps track of the driverName upon Open,
// used mostly to automatically bind named queries using the right bindvars.
type DB struct {
*sql.DB
driverName string
unsafe bool
Mapper *reflectx.Mapper
}
// NewDb returns a new sqlx DB wrapper for a pre-existing *sql.DB. The
// driverName of the original database is required for named query support.
func NewDb(db *sql.DB, driverName string) *DB {
return &DB{DB: db, driverName: driverName, Mapper: mapper()}
}
// DriverName returns the driverName passed to the Open function for this DB.
func (db *DB) DriverName() string {
return db.driverName
}
// Open is the same as sql.Open, but returns an *sqlx.DB instead.
func Open(driverName, dataSourceName string) (*DB, error) {
db, err := sql.Open(driverName, dataSourceName)
if err != nil {
return nil, err
}
return &DB{DB: db, driverName: driverName, Mapper: mapper()}, err
}
I perform four different INSERT types in my program and I want to batch them. Normal usage of BatchInsert doesn't allow it (result: sql expected arguments error). I know I could create four different DB's but SQLite would not handle that.
What about restructuring your lib (without breaking API) to provide support for different INSERTs? It would be really great feature.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.