aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/mssql/README.md
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/mssql/README.md
downloadcli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/mssql/README.md')
-rw-r--r--v_windows/v/vlib/mssql/README.md69
1 files changed, 69 insertions, 0 deletions
diff --git a/v_windows/v/vlib/mssql/README.md b/v_windows/v/vlib/mssql/README.md
new file mode 100644
index 0000000..ff4fefc
--- /dev/null
+++ b/v_windows/v/vlib/mssql/README.md
@@ -0,0 +1,69 @@
+# SQL Server ODBC
+
+* This is a V wrapper of SQL Server ODBC C/C++ library
+
+## Dependencies
+* ODBC C/C++ library
+ * Linux Install:
+ * Details: https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
+ * `msodbcsql17` and `unixodbc-dev` packages are needed
+ * Windows Install:
+ * `odbc` lib is included in windows sdk for most of distributions,
+ so there is no need to install it separately
+ * Details: https://docs.microsoft.com/en-us/sql/connect/odbc/microsoft-odbc-driver-for-sql-server
+
+## 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:
+```cmd
+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
+```v ignore
+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
+ }
+}
+```