gosexy / db Goto Github PK
View Code? Open in Web Editor NEW(Deprecated. See upper.io/db)
(Deprecated. See upper.io/db)
Excuse me, I speak English badly.
first:
We know, Maps are not safe for concurrent use.
So,maybe better for access collections of struct Source.
Second:
github.com/xiam/gosqlite3
github.com/xiam/gopostgresql
not synchronization with original package.
Original package has been updated to improve a lot.
Is not possible to use the original package.
Also
Expect to solve #12 soon as possible
It instead just makes its own error, making it unknown what error was caused.
Could results of a query be returned into a slice?
mgo does something like this using an iterator - Iter()
https://github.com/xushiwei/mgo/blob/master/src/labix.org/v2/mgo/session.go#L2209
For instance:
//
// var result []struct{ Value int }
// iter := collection.Find(nil).Limit(100).Iter()
// err := iter.All(&result)
// if err != nil {
// panic(iter.Err())
// }
I'd love to use gosexy with my company's legacy Oracle DBs (9i ~ 11g).
Under https://menteslibres.net/gosexy/db/wrappers/sqlite, there is an error with the documentation.
Under "Connecting to a SQLite3 database":
sess, err := db.Open("mongo", db.DataSource{Database: "/path/to/sqlite3.db", ...})
It should be:
sess, err := db.Open("sqlite", db.DataSource{Database: "/path/to/sqlite3.db", ...})
It appears that the sqlite wrapper fails to build.
Error log:
wei2912@wei-lm-desktop ~/.dropbox-files/Dropbox/Documents/GitHub/db/sqlite $ go test
# _/home/wei2912/.dropbox-files/Dropbox/Documents/GitHub/db/sqlite
./collection.go:57: undefined: db.ErrQueryLimitParam
./collection.go:76: undefined: db.ErrQuerySortParam
./collection.go:82: undefined: ErrQueryOffsetParam
./collection.go:267: undefined: db.ErrMissingConditions
./sqlite.go:117: undefined: db.ErrNotConnected
./sqlite.go:137: undefined: db.ErrNotConnected
./sqlite.go:157: undefined: db.ErrNotConnected
./sqlite.go:195: undefined: db.ErrMissingDatabaseName
./sqlite.go:284: undefined: db.ErrCollectionDoesNotExists
FAIL _/home/wei2912/.dropbox-files/Dropbox/Documents/GitHub/db/sqlite [build failed]
When I 'm trying to insert something with command collection.Append(), I get empty result id and in MongoDB occurs record with {"_id": null}, and when I'm appending some new record, I get this record with null id updated.
go version go1.3.1 linux/amd64
MongoDB shell version: 2.6.4
If you run the TestRelation function, it doesn't print out what it's suppose to.
I get the following:
relations (1) []db.Item{
db.Item{"name":"Joseph", "id":2, "place_code_id":3},
db.Item{"place_code_id":1, "id":3, "name":"Pedro"},
db.Item{"name":"María", "id":4, "place_code_id":0},
db.Item{"id":5, "place_code_id":1, "name":"Roberto"},
db.Item{"id":6, "place_code_id":2, "name":"Manuel"},
db.Item{"place_code_id":1, "id":7, "name":"Miguel"},
}
it seems to be missing the lives_in, has_children, and has_visited. I see this in my own application as well.
Hi,
First of all, congrats on gosexy/db. Really nice piece of work!
Does db.Sort support other databases except MongoDB? I tried this line on a PostgreSQL database with no luck.
items := messages.FindAll(db.Sort{"timestamp": "DESC"})
Is there something I am doing wrong or is the support missing for now?
Thanks!
Jamie
gosexy/db tends to work slowly. I haven't benchmarked any results yet, but will do so as soon as possible. Right now, it appears to be one insert per second.
Using sqlite wrapper.
We had ugly workarounds for the lack of reflect.MapOf and reflect.SliceOf, now that go1.1 is available we should use proper methods.
In SQL, BEGIN and END are used as transaction delimiters. PostgreSQL, SQLite3 and MySQL support this syntax, MongoDB does not, but we can add an empty method as a placeholder in the hope it gets implemented someday.
This issue is closely related to #20.
Is there a way to do "like" matching without doing raw SQL? E.g. "select * from table where column like "%something%".
If there isn't, maybe there needs to be a new db.Cond or maybe if it detects a %, it can do a LIKE automatically. Let me know your thoughts.
in db/sqlite/collection.go
return nil, ErrQueryOffsetParam
should be
return nil, db.ErrQueryOffsetParam
I ran into an interesting problem while testing my application with postgresql and mongodb. Part of the application finds rows within a certain date range. While this works in mongodb just fine, it doesn't work in postgresql.
This works in mongodb:
res, err := cp.Query(
db.And{
db.Cond{"date >=": dateFrom},
db.Cond{"date <=": dateTo},
},
)
and this makes it work in postgresql:
res, err := cp.Query(
db.And{
db.Cond{"date >=": dateFrom.Format("2006-01-02 15:04:05")},
db.Cond{"date <=": dateTo.Format("2006-01-02 15:04:05")},
},
)
Because in the postgresql example, inside the compileStatement()
function it just uses to.String()
to convert the values. Would it be possible that this instead uses toInternal()
? Because that function will format the date correctly.
code.google.com/p/go-mysql-driver/mysql allows you to specify a charset, so it would be nice to do it in gosexy.
The date format is assumed to be this:
2006-01-02 15:04:05
but in sqlite3, the date returned is in this format:
3/9/2009 12:00:00 AM
Not sure what the solution to this is, as I can see the time stuff was commented out of your forked version of gosqlite3.
In both the mysql and sqlite wraper, in collection.FindAll, there is code like this:
rows, _ := t.parent.doQuery(
fmt.Sprintf("SELECT %s FROM %s", fields, t.Name()),
fmt.Sprintf("WHERE %s", conditions), args,
sort, limit, offset,
)
it doesn't check for an error. If doQuery throws an error (like a column not existing), then it will panic with a nil reference instead of panicing with an error that described what actually happened.
It would be nice if the API like session.Collection() and other API methods would return value, err instead of throwing a panic when something goes wrong.
From http://blog.golang.org/2010/08/defer-panic-and-recover.html :
The convention in the Go libraries is that even when a package uses panic internally, its external API >still presents explicit error return values.
So it's fine if you internally use panic, but at some point it needs to return an explicit error value to the user instead of panicing.
I'm just spit balling here, but sometimes we have to use Driver() to do complicated specialized queries. It would be nice if in those situations, we could get a db.Item. Maybe by exposing fetchRows() or making an API that calls that.
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.