question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: can I use a regular connection string?

See original GitHub issue

Can I use a regular connection string with this library?

Docs: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING

Examples:

postgresql://
postgresql://localhost
postgresql://localhost:5432
postgresql://localhost/mydb
postgresql://user@localhost
postgresql://user:secret@localhost
postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
postgresql://localhost/mydb?user=other&password=secret

I would expect to be able to do something like this:

let! data = 
  "postgresql://user:secret@localhost"
  |> Sql.connect
  |> Sql.query "SELECT * FROM some_table"
  |> Sql.executeTableAsync

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jchannoncommented, Jun 12, 2020

I just discovered that 60secs before you reply! Thanks

1reaction
Zaid-Ajajcommented, Jun 12, 2020

Hi @jchannon, you can use the literal string as input for the Sql.connect function and do stuff from that point on:

"Server=localhost;Database=myDb;Uid=foo;Pwd=bar;"
|> Sql.connect
|> Sql.query "SELECT * FROM users"
|> Sql.execute (fun read -> read.string "username")
Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Anything wrong with putting connection strings in ...
Does "standardize" in this case mean that your classes would directly acquire the connection string/other settings by using ...
Read more >
SQL Connection Strings tips
This article will show some useful tips about SQL connection strings.
Read more >
Connection String URI Format
Connection String Formats​​ You can specify the MongoDB connection string by using either: Standard Connection String Format. SRV Connection Format.
Read more >
Password character issues for } and ' in SQL connection ...
I will try and list some of the obvious reasons and some other maybe not so obvious reasons why some characters fail when...
Read more >
Connect with sqlplus from the command line using a ...
I have a username = x, password = y, database = z, port = a, SID = b, and Hostname = c. So,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found