Skip to content

Instantly share code, notes, and snippets.

@mdnmdn
Last active August 29, 2023 23:55
Show Gist options
  • Save mdnmdn/c06feb1fc77cfbf0a8912203b34fe751 to your computer and use it in GitHub Desktop.
Save mdnmdn/c06feb1fc77cfbf0a8912203b34fe751 to your computer and use it in GitHub Desktop.
Mix.install([
{:postgrex, "~> 0.15.0"}
])
{defmodule MyMod do
def main do
{:ok, pid} =
Tds.start_link(
hostname: "localhost",
username: "sa",
password: "io",
database: "master",
port: 1443
)
# IO.inspect(Tds.query!(pid, "SELECT * from information_schema.tables ", []))
# IO.inspect(Tds.query!(pid, "SELECT * from information_schema.tables where table_catalog = @1 ", ["master"]))
IO.inspect(
Tds.query!(pid, "SELECT * from information_schema.tables where table_catalog = @tbl ", [
%Tds.Parameter{name: "@tbl", value: "master"}
])
)
end
end
MyMod.main()
Mix.install([
{:tds, "~> 2.0"}
])
# alias Tds.Parameter
{:ok, pid} =
Tds.start_link(
hostname: "localhost",
username: "sa",
password: "io",
database: "master",
port: 1443
)
# IO.inspect(Tds.query!(pid, "SELECT * from information_schema.tables ", []))
# IO.inspect(Tds.query!(pid, "SELECT * from information_schema.tables where table_catalog = @1 ", ["master"]))
IO.inspect(
Tds.query!(pid, "SELECT * from information_schema.tables where table_catalog = @tbl ", [
%Tds.Parameter{name: "tbl", value: "master"}
])
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment