Hi Marcin,

I know about Prepare function supported by sql package .My initial question
was what is better way to pass multiple prepare statements on different
http handlers .
ex: we can construct struct like this

type Database struct {
    db *sql.DB

    someStmt *sql.Stmt
    // etc.
}
but since we have multiple prepare statements this struct will keep on
increasing so my question was is there any better way provided in golang
like in java (where we can initialize prepare statement in class
constructor and use that )

On Sun, Apr 14, 2019 at 7:59 AM Marcin Romaszewicz <marc...@gmail.com>
wrote:

> Do you mean a SQL prepared statement?
>
> Check out the database/sql package. The database connection abstraction
> has a Prepare function which creates a statement. Keep in mind, that based
> on your level of concurrency, the statement will be re-prepared in each new
> connection that's opened up on your behalf. So, what you need to do is keep
> a persistent instance of sql.DB, which will try to maintain your prepared
> statements for you.
>
>
> On Sat, Apr 13, 2019 at 10:58 AM <shrinath...@gmail.com> wrote:
>
>> Hi Team ,
>> I am new in go lang ,I want to know is there any recommended way in go
>> lang to create prepare statement in go lang on application start and pass
>> it to multiple http handler so that query can be done inside those http
>> handlers.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 

Thanks and Regards,



Shri Nath Agarwal

Mobile 9482060723

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to