v/vlib/mssql
Daniel Däschle d679146a80
fmt: remove space in front of ? and ! (#14366)
2022-05-13 06:56:21 +03:00
..
README.md fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
_cdef_nix.c.v vlib: add a vlib/mssql module (#10280) 2021-05-31 14:08:31 +03:00
_cdef_windows.c.v mssql: support windows (#10336) 2021-06-07 14:02:15 +03:00
_cdefs.c.v mssql: fix c function definition parameters (#11307) 2021-08-25 14:39:56 +03:00
config.v mssql: support orm create and drop table (#10296) 2021-06-01 11:10:27 +03:00
mssql.v fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
result.v vlib: add a vlib/mssql module (#10280) 2021-05-31 14:08:31 +03:00
stmt_handle.v fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00

README.md

SQL Server ODBC

  • This is a V wrapper of SQL Server ODBC C/C++ library

Dependencies

Windows Notes

Using msvc

  • Make sure cl.exe of msvc is accessible from command line. You can run v commands in Visual Studio 2019 Developer Command Prompt to be safe.
  • C Headers and dlls can be automatically resolved by msvc.

Using tcc

  • Copy those headers to @VEXEROOT\thirdparty\mssql\include. The version number 10.0.18362.0 might differ on your system. Command Prompt commands:
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\sql.h" thirdparty\mssql\include
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\sqlext.h" thirdparty\mssql\include
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\sqltypes.h" thirdparty\mssql\include
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\sqlucode.h" thirdparty\mssql\include
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\sal.h" thirdparty\mssql\include
copy "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\concurrencysal.h" thirdparty\mssql\include
  • dlls can be automatically resolved by tcc

TODO

  • Support Mac
  • Support ORM

Usage

import mssql

fn test_example() ? {
	// connect to server
	config := mssql.Config{
		driver: 'ODBC Driver 17 for SQL Server'
		server: 'tcp:localhost'
		uid: '<your username>'
		pwd: '<your password>'
	}

	mut conn := mssql.Connection{}

	conn.connect(config.get_conn_str())?

	defer {
		conn.close()
	}

	// get current db name
	mut query := 'SELECT DB_NAME()'
	mut res := conn.query(query)?
	assert res == mssql.Result{
		rows: [mssql.Row{
			vals: ['master']
		}]
		num_rows_affected: -1
	}
}