-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support for parameters in multiple statements #2
Comments
Could you please explain more precisely? I'm not sure i can understand what are you trying to achieve... |
Are you are talking about this limitation? import asyncdispatch, asyncpg, strutils
proc multipleStatements(conn: apgConnection) {.async.} =
# Execute multiple SELECT operations
# Only text SQL queries are supported, you cannot separate
# parameters from query, e.g.
# var r = await conn.exec("SELECT $1; SELECT $2; SELECT $3", 1, 2, 3)
var r = await conn.exec("SELECT 1; SELECT 2; SELECT 3")
# Get number of results
var resultsCount = len(r)
echo "Results count = " & $resultsCount
# Echo first result
echo getValue(r[0])
# Echo second result
echo getValue(r[1])
# Echo third result
echo getValue(r[2])
# Close results
close(r)
var connStr = "host=localhost port=5432 dbname=travis_ci_test user=postgres"
var conn = waitFor connect(connStr)
waitFor conn.multipleStatements()
conn.close() |
Yes that it is correct. I see you have a line commented out. Would this be a difficult enhancement? |
This is problemmatic, just because i'm using
https://www.postgresql.org/docs/current/static/libpq-exec.html#LIBPQ-PQEXECPARAMS |
To implement it by myself i need to have SQL parser with support of all PostgreSQL extensions, and this is pretty tough work. |
Thanks for the update. Sounds complex. I wonder if it might be easier creating a PL/Nim Library by wrapping PL/C with some kind of easy deployment mechanism of the generated dynamic libraries. |
Hi thanks for the great work.
Can we please have support for parameters in multiple statements?
There seems to be some work complete on this for https://github.com/tulayang/asyncmysql so would be good if the Postgres version also supported this.
The text was updated successfully, but these errors were encountered: