GithubHelp home page GithubHelp logo

go-pgsql's People

Contributors

andrewzeneski avatar lxn avatar samuel avatar saschpe avatar serverhorror avatar stianl avatar temoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-pgsql's Issues

COPY table from stdin

Hello.

Could you make it clear - is it possible to perform bulk load of data via COPY table from stdin; statement using go-pgsql? If yes, how?

P.S.: Thank you for this project. You really filled an empty space of pure Go implementation of such important protocol.

Pools...

I'll observe that another Go/PG binding is on GitHub, https://github.com/jbarham/pgsql.go, which take the alternative approach of wrapping libpq.

It handles the thread safety issue by implementing a connection pool mechanism.

I don't know if it's a better thing to try to merge code in one direction or another; I simply observe that it's worth taking a peek at it to see what's worth adapting in either direction.

go-pgsql can not handle CHAR type field

CREATE TABLE test8 (aaa CHAR(10));
INSERT INTO test8 (aaa) VALUES ('aaaa');

rs,err := db.Query("SELECT aaa FROM test8")

error message:

Error: unexpected field data type

go1.3 compatibility issue

Hello Alexander,

I have upgrade to go 1.3 and the code using your library errors with this sort of log :

2014/06/27 12:20:48 Error: write tcp 127.0.0.1:5432: i/o timeout
Stack Trace:
=======================================================
github.com/lxn/go-pgsql.panicIfErr (/Users/oayoun/Developer/go/src/github.com/lxn/go-pgsql/util.go, Line 9)
-------------------------------------------------------
github.com/lxn/go-pgsql.(*Conn).flush (/Users/oayoun/Developer/go/src/github.com/lxn/go-pgsql/conn_write.go, Line 18)
-------------------------------------------------------
github.com/lxn/go-pgsql.(*Conn).writeStartup (/Users/oayoun/Developer/go/src/github.com/lxn/go-pgsql/conn_write.go, Line 331)
-------------------------------------------------------
github.com/lxn/go-pgsql.Connect (/Users/oayoun/Developer/go/src/github.com/lxn/go-pgsql/conn.go, Line 324)
-------------------------------------------------------
vostok.(*Appserv).Start (/Users/oayoun/Developer/go/src/vostok/vostok.go, Line 2129)
-------------------------------------------------------
main.main (/Users/oayoun/Developer/go/src/hydra/server.go, Line 845)
-------------------------------------------------------
runtime.main (/_DEV/go/src/pkg/runtime/proc.c, Line 247)
-------------------------------------------------------
runtime.goexit (/_DEV/go/src/pkg/runtime/proc.c, Line 1445)
=======================================================
panic: [VOSTOK:vostok:Start] !!! could not start the database connection : write tcp 127.0.0.1:5432: i/o timeout !!!

I am currently looking into the issue within the source to find out what could have changed. I'll obviously keep you posted.

Oscar

decimal implemented as big.Rat instead of float64

I've written a test program for some of the database/sql packages. The others that I've tested to-date use a float64 for decimal values eg. "dbalance decimal(12,2) not null)" is scanned using a float64 as receiving value for the other 2 packages I've tested. From the testing that I've done, it would appear that this package uses big.Rat for decimal values. AFAIK and as determined from my testing to-date, float64 is perfectly adequate for decimal/currency values. In order to perform calculations, I convert them to an int64 to avoid rounding errors. I've partly altered my test program to cater for big.Rat,

I'm wondering if there is a particular reason for using big.Rat data-type instead of float64, and whether float64 may be more "standard"? I've partly implemented big.Rat in my test program, but thought it worth asking the question before completing the change, as float64 may have more general appeal.

LastInsertId method returns 0?

I don't know if this driver implements the LastInsertId method of the Result type of the database/sql package or not but when I tried to use it I got back a 0 but in Postgres I could see the last ID was 98.

The way that I tried it out is as follows:

result, err := db.Exec("insert into commands (command,slot) values ($1,$2)", incoming.Command, incoming.Slot)
if err != nil {
    l.Printf("Error inserting into the commands table: %v\n", err)
    return
}

id, _ := result.LastInsertId()
fmt.Println(id) //Prints 0

generated Keys

apologies if this is incorrect...

Support on Execute for returning any generated keys as the result of statement. An example in Java would be:

Statement stmt = conn.createStatement();
stmt.execute(sql, Statement.RETURN_GENERATED_KEYS);
ResultSet keyset = stmt.getGeneratedKeys();

Directory layout

I just start using pgsql and I like it. Good functionality and it seems to be pretty well documented. So thank you for that =)

But I don't like the directory layout introduced in commit (6cf4313). It's really cumbersome when installed with goinstall, and in general it's a little more than necessary.

If installed with goinstall, the import path in Go source files is really complicated and hard to remember.

import "github.com/lxn/go-pgsql/src/pkg/pgsql"

(It doesn't really make since to have a directory /src/ in the import path either, because you're importing a binary file.)

The source files (in /src/pkg/pgsql) should be moved to /pgsql. It is the Go convention. So it gives a shorter, easy to remember import path.

import "github.com/lxn/go-pgsql/pgsql"

I think the examples were good in the /examples directory. The project wouldn't be cluttered, imho.

Please consider this. I think its really annoying the way it is. But otherwise, thanks again for this package! And please keep up the great work!

Example for insert query with placeholders?

Is it possible if you would add, or at least explain, how go-pgsql expects querys with place holders to be done?

In my current code I am doing this:

tx, err := db.Begin()
stmt, err := tx.Prepare("insert into foo (number, value) values (?,?)")
if err != nil {
    fmt.Println(err)
    db.Close()
    os.Exit(1)
}
derfer stmt.Close()

_, err = stmt.Exec("Twelve", 12)
if err != nil {
    fmt.Println(err)
    db.Close()
    os.Exit(1)
}
tx.Commit()

Doing so gives this error:

        Code: 42601
        Message: syntax error at or near ","
        Detail: 
        Hint: 
        Position: 39
        Internal Position: 
        Internal Query: 
        Where: 
        File: scan.l
        Line: 1001
        Routine: scanner_yyerror
exit status 1

I am using go version weekly.2012-03-04 +5c664f190e4e as well as the database/sql package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.