From 2425c08bc372809c28bea021cd9ed0de3b8eebb2 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 13 Feb 2020 20:14:39 +0700 Subject: sql: a new package as an extension to "database/sql" --- lib/sql/session.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/sql/session.go (limited to 'lib/sql/session.go') diff --git a/lib/sql/session.go b/lib/sql/session.go new file mode 100644 index 00000000..dec4b0cd --- /dev/null +++ b/lib/sql/session.go @@ -0,0 +1,24 @@ +// Copyright 2020, Shulhan . All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sql + +import ( + "context" + "database/sql" +) + +// +// Session is an interface that represent both sql.DB and sql.Tx. +// +type Session interface { + Exec(query string, args ...interface{}) (sql.Result, error) + ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + Prepare(query string) (*sql.Stmt, error) + PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) + Query(query string, args ...interface{}) (*sql.Rows, error) + QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + QueryRow(query string, args ...interface{}) *sql.Row + QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row +} -- cgit v1.3