odbc

command
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

Venom - Executor SQL

This executor is a plugin executor. You need to recompile venom with plugin support to use it.

$ git clone https://github.com/ovh/venom.git
$ cd venom
$ make build
$ make plugins
$ # venom binary is generated into dist directory
$ # plugin binary is generated into dist/lib directory
$ cd dist
$ ./venom run ... 

To compile this executor, you need an ODBC driver. Please read https://github.com/alexbrainman/odbc/wiki

Example on osx with driver installed with homebrew:

$ CGO_CFLAGS="-I$HOME/homebrew/Cellar/unixodbc/2.3.9/include" CGO_LDFLAGS="-L$HOME/homebrew/lib" go build

Step to execute SQL queries into databases:

  • ODBC

It use the package sqlx under the hood: https://github.com/jmoiron/sqlx to retrieve rows as a list of map[string]interface{}

Input

In your yaml file, you declare your step like this

  - dsn mandatory
  - commands optional
  - file optional
  • commands is a list of SQL queries.
  • file parameter is only used as a fallback if commands is not used.

Example usage (mysql, oracle, SQLServer):

name: Title of TestSuite
testcases:

  - name: Query database
    steps:
      - type: odbc
        dsn: user:password@(localhost:3306)/venom
        commands:
          - "SELECT * FROM employee;"
          - "SELECT * FROM person;"
        assertions:
          - result.queries.__len__ ShouldEqual 2
          - result.queries.queries0.rows.rows0.name ShouldEqual Jack
          - result.queries.queries1.rows.rows0.age ShouldEqual 21

Example with a query file:

name: Title of TestSuite
testcases:

  - name: Query database
    steps:
      - type: odbc
        database: thedatabase
        dsn: user:password@(localhost:3306)/venom
        file: ./test.sql
        assertions:
          - result.queries.__len__ ShouldEqual 1

*note: in the example above, the results of each command is stored in the results array

SQL drivers

This executor uses the following SQL drivers:

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL