mcfunley / pugsql

A HugSQL-inspired database library for Python
https://pugsql.org
Apache License 2.0
673 stars 22 forks source link

add self.engine in compiler.py? #5

Closed swuecho closed 3 years ago

swuecho commented 5 years ago

make it convenient to get the engine, in case user need it to do some custom query.

mcfunley commented 5 years ago

Hey thanks!

Would this be the same as just needing a way to compile a query at runtime? Someone else brought that up. There's not a fantastic way to accomplish this now.

Maybe something like this sketch?

queries = pugsql.compile(path)

# later
queries.add('newquery', sql_string)

results = queries.newquery(**params)

add is probably too generic of a name for it but that'd be the idea.

swuecho commented 5 years ago

This is also helps. but sometimes, for example, I want to run query on each table. The param is the table_name, which sqlalchemy will add extra ''. The query can not be run through pugsql. In situation like this, a connection is necessary.

if this is something can be considered, I am happy to make a pull request.

jroxendal commented 4 years ago

I was just looking for something like the add above!

mcfunley commented 3 years ago

released in 0.2.2