How to use transactions #1479
              
                
                  
                  
                    Answered
                  
                  by
                    Jille
                  
              
          
                  
                    
                      KabudoWiseMan
                    
                  
                
                  asked this question in
                Q&A
              
            -
| I'm new to sqlc and I don't really understand the example "Using transactions" in docs. So how can I create a function that uses a transaction as for database/sql: function FuncTx() {
	// some code
	tx, err := db.BeginTx(ctx, nil)
	if err != nil {
		log.Fatal(err)
	}
	// do something
	tx.Commit()
} | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            Jille
          
      
      
        May 2, 2022 
      
    
    Replies: 1 comment 1 reply
-
| You can simply pass the   | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
      Answer selected by
        KabudoWiseMan
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
You can simply pass the
txto the New() function of the generated package.