Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learning from SQL Server #2210

Open
krlmlr opened this issue Apr 13, 2024 · 0 comments
Open

Learning from SQL Server #2210

krlmlr opened this issue Apr 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@krlmlr
Copy link
Collaborator

krlmlr commented Apr 13, 2024

Gives a weird dm?

CC @TSchiefer.

suppressPackageStartupMessages(library(dm))

packageVersion("dm")
#> [1] '1.0.10.9005'
packageVersion("DBI")
#> [1] '1.2.2'
packageVersion("dbplyr")
#> [1] '2.4.0.9000'

# connection to any SQL SERVER DB, please create one that works for you
con <- DBI::dbConnect(
  odbc::odbc(),
  # driver = "ODBC Driver 18 for SQL Server",
  driver = "SQL Server Driver",
  server = Sys.getenv("DM_TEST_DOCKER_HOST"),
  uid = "SA",
  pwd = "YourStrong!Passw0rd",
  port = 1433,
  TrustServerCertificate = "yes"
)

db_schema_create(con, "test")
#> Schema `test` created.
DBI::dbWriteTable(con, DBI::Id(schema = "test", table = "mtcars"), mtcars)

remote_dm <- dm_from_con(con, schema = "test")
#> Keys queried successfully.
#> ℹ Use `learn_keys = TRUE` to mute this message.
remote_dm
#> ── Table source ────────────────────────────────────────────────────────────────
#> src:  Microsoft SQL Server 15.00.2000[@c15a9261a545/master]
#> ── Metadata ────────────────────────────────────────────────────────────────────
#> Tables: `mtcars`
#> Columns: 12
#> Primary keys: 0
#> Foreign keys: 0

# here is the problem: the remote name is `NA`
remote_dm$mtcars %>% dbplyr::sql_render()
#> <SQL> SELECT *
#> FROM NA

DBI::dbExecute(con, "DROP TABLE test.mtcars")
#> [1] 0
db_schema_drop(con, "test")
#> Dropped schema `test`.
@krlmlr krlmlr added the bug Something isn't working label Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant