How to generate SQL string without connecting to any database?

16 views
Skip to first unread message

paulo....@gmail.com

unread,
Nov 10, 2020, 7:52:04 AM11/10/20
to web2py-users

Hi!

I was previously (web2py 2.18.5) using postgres:pg8000 adapter and a dummy connection string with the parameter do_connect=False in order to be able to generate  SQL query strings without actually connecting to any database.

I see that with the latest version (2.20.4) the "do_connect" was removed, and on post by Massimo on this group he says the connection will be delayed until it is really required. Unfortunately this doesn't seem to be 100% accurate, since either the DAL initialization or the _select method is triggering a connection to the database, requiring me to have a valid DB connection, even though I never actually send the query to the database.

Is there a way to get the SQL without requiring a valid DB connection? (I know its an odd setup, a portion on my "BD" is actually behind an web API and all I need is to push a SQL string. I can of course reuse the credentials for portion of data that sits on a standard SQL database, and open a connection to it just to generate SQL string, but I would like to avoid that if possible).

Reply all
Reply to author
Forward
0 new messages