# Connecting Tidier with MSSQL

**URL:** https://discourse.julialang.org/t/connecting-tidier-with-mssql/121018
**Category:** Data
**Tags:** question, package
**Created:** [October 7, 2024, 4:39pm UTC](https://discourse.julialang.org/t/connecting-tidier-with-mssql/121018 "2024-10-07T16:39:43Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [October 7, 2024, 5:19pm UTC](https://discourse.julialang.org/t/connecting-tidier-with-mssql/121018/2 "2024-10-07T17:19:31Z")

</div>

I would first try to connect some way without Tidier (and then you might only need TiderDB):

> **[Working with MS SQL Server in Julia](https://towardsdatascience.com/working-with-ms-sql-server-in-julia-fc6fcd55d69a)**
>
> Time to supercharge your data analysis workflow

> [@Julia, ODBC connection to a remote MS SQL Server](https://discourse.julialang.org/t/julia-odbc-connection-to-a-remote-ms-sql-server/75374/2):
>
> Ok, this is what I’m trying, and I know generally that the variables are correct. julia\> ODBC.drivers() Dict{String, String} with 2 entries: "ODBC Drivers" =\> "" "ODBC Driver 17 for SQL Server" =\> "Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1\0UsageCount=6\0" julia\> ODBC.Connection(Driver={ODBC Driver 17 for SQL Server};Server="server\_ip#";Database="DBaseName";UID="User.Name";PWD="passwor") ERROR: syntax: invalid comprehension syntax Stacktrace: [1] to…

Also you’re doing something more than me, since I get less specific error message:

```julia
julia> using Tidier

julia> using ODBC

julia> db = DB.connect(:mssql, "Driver={ODBC Driver 17 for SQL Server};Server=my.sqlserver=Reporting;Trusted_Connection=yes;")
ERROR: UndefVarError: `DB` not defined

```

Something like this errors for me (expectedly) but should work for you:

```julia
julia> julia> con = ODBC.Connection("Driver={ODBC Driver 17 for SQL Server};Server=my.sqlserver=Reporting;Trusted_Connection=yes;") # or similar to ODBC.Connection("Driver=ODBC Driver 17 for SQL Server;SERVER=ip#,DATABASE=dbname,UID=username,PWD=passwrod")
ERROR: 01000: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found

```

You might want to make sure if you have latest versions with `st` (though I doubt it was the problem), I noticed I didn’t have latest (and ironically trying to fix downgraded):

```julia
pkg> add Tidier@v1.4.0

⌅ [4acbeb90] ↓ Stipple v0.30.7 ⇒ v0.28.14
  [2b41e42f] ↑ StippleMarkdown v0.0.1 ⇒ v0.2.0
  [f0413319] ↑ Tidier v1.3.0 ⇒ v1.4.0
⌅ [86993f9b] ↓ TidierDB v0.4.1 ⇒ v0.1.9
    Updating `~/Manifest.toml`
...
⌅ [458c3c95] ↓ OpenSSL_jll v3.0.15+1 ⇒ v1.1.23+1 [and many more than this, what I don't like about Julia's defaults]

pkg> add TidierDB@v0.4.1
   Resolving package versions...
   Installed JuliaFormatter ─ v1.0.61
    Updating `~/Project.toml`
⌃ [f0413319] ↓ Tidier v1.4.0 ⇒ v1.3.0
  [86993f9b] ↑ TidierDB v0.1.9 ⇒ v0.4.1
...

```

I’m not exactly sure what’s blocking, I see in “[compat]” (and should be ok?): TidierDB = “0.1, 1”:

```julia
(pharaldsson) pkg> add TidierDB@v0.4.1 Tidier@v1.4.0
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package TidierDB [86993f9b]:
 TidierDB [86993f9b] log:
 ├─possible versions are: 0.1.0-0.4.1 or uninstalled
 ├─restricted to versions 0.4.1 by an explicit requirement, leaving only versions: 0.4.1
 └─restricted by compatibility requirements with Tidier [f0413319] to versions: 0.1.0-0.1.9 — no versions left
   └─Tidier [f0413319] log:
     ├─possible versions are: 0.3.0-1.4.0 or uninstalled
     └─restricted to versions 1.4.0 by an explicit requirement, leaving only versions: 1.4.0

```

I think on Windows you have ODBC preinstalled (the non-Julia support), elsewhere you also likely need to do something like (I even gave up trying to set up in R…):

```julia
$ apt-get install unixodbc-dev

```

> <https://github.com/r-dbi/odbc/issues/236#issuecomment-434463291>
>
> \### Issue Description and Expected Result
> I call install.packages("odbc") and t…he odbc package to be installed
> 
> \### Database
> 
> 
> \### Reproducible Example
> \<!--
> If possible include a \_small\_ dump of the table with the error and the R code
> that generates the error. In your reprex please use \`con\` as the name of the
> connection, this makes it easier to run locally.
> 
> The reprex package can be helpful in doing this.
> 
> install.packages("reprex")
> reprex::reprex()
> 
> Example:
> \`\`\`r
> library(odbc)
> library(DBI)
> con \<- dbConnect(odbc::odbc(), dsn = "PostgreSQL")
> dbWriteTable(con, "iris", iris)
> dbReadTable(con, "iris")
> \`\`\`
> \--\>
> \<summary\>This happens both on RStudio Server (R version 3.5.1) and on Ubuntu 16.04 with R version 3.2.3\</summary\>
> 
> \`\`\`r
> install.packages("odbc")
> 
> Installing package into ‘/usr/local/lib/R/site-library’
> (as ‘lib’ is unspecified)
> trying URL 'https://cran.rstudio.com/src/contrib/odbc\_1.1.6.tar.gz'
> Content type 'application/x-gzip' length 288033 bytes (281 KB)
> ==================================================
> downloaded 281 KB
> 
> \* installing \*source\* package ‘odbc’ ...
> \*\* package ‘odbc’ successfully unpacked and MD5 sums checked
> PKG\_CFLAGS=
> PKG\_LIBS=-lodbc
> \<stdin\>:1:17: fatal error: sql.h: No such file or directory
> compilation terminated.
> \------------------------- ANTICONF ERROR ---------------------------
> Configuration failed because odbc was not found. Try installing:
> \* deb: unixodbc-dev (Debian, Ubuntu, etc)
> \* rpm: unixODBC-devel (Fedora, CentOS, RHEL)
> \* csw: unixodbc\_dev (Solaris)
> \* brew: unixodbc (Mac OSX)
> To use a custom odbc set INCLUDE\_DIR and LIB\_DIR manually via:
> R CMD INSTALL --configure-vars='INCLUDE\_DIR=... LIB\_DIR=...'
> \--------------------------------------------------------------------
> ERROR: configuration failed for package ‘odbc’
> \* removing ‘/usr/local/lib/R/site-library/odbc’
> Warning in install.packages :
> installation of package ‘odbc’ had non-zero exit status
> 
> The downloaded source packages are in
> ‘/tmp/RtmpDXgKkI/downloaded\_packages’
> \`\`\`

---

_[View the full topic](https://discourse.julialang.org/t/connecting-tidier-with-mssql/121018)._
