sqlalchemy core is a better option than going straight to the driver imo.
And you can call postgresql functions from the session, however if you are
using pyramid transaction and zope.sqlalchemy you will want to get in the
habit of marking the transactions as changes were made for the functions
that mutate data...


from zope.sqlalchemy import mark_changed
from sqlalchemy import func
result = session.execute(func.my_pg_func(*params)).scalar()
mark_changed(session)


On Mon, Aug 15, 2022 at 6:46 PM Jonathan Vanasco <jvana...@gmail.com> wrote:

>
> I second what Michael said.  The sqlalchemy starter template is the right
> way to go.
>
> The major thing this template does, is provide you with the glue between a
> SQLAlchemy "Session" and the pyramid request.  See :
> https://github.com/Pylons/pyramid-cookiecutter-starter/blob/latest/%7B%7Bcookiecutter.repo_name%7D%7D/%7B%7Bcookiecutter.repo_name%7D%7D/sqlalchemy_models/__init__.py#L87-L127
>
> If you run pyramid_tm (https://pypi.org/project/pyramid-tm/) you can then
> use zope.sqlalchemy (https://pypi.org/project/zope.sqlalchemy/) to bind
> the session to the transaction.
>
> You don't need to use SQLAlchemy's ORM.  You can just use SQLAlchemy Core (
> https://docs.sqlalchemy.org/en/14/core/) to do everything.  You can also
> access the underlying psycopg2 connections through SQLAlchemy when you want.
>
> There is not a lot of code to rewrite if you want to eliminate SqlAlchemy
> and start from scratch - probably only 100-400 lines worth, and as Arndt
> Droullier said it is pretty straightforward -- but you're going to have to
> maintain that, and the entrypoints are somewhat rough.  Even in that
> situation, starting with the sqlalchemy cookiecutter is your best option as
> it will give you a better idea as to where your code needs to go.
>
>
> On Thursday, August 11, 2022 at 12:38:36 PM UTC-4 mmer...@gmail.com wrote:
>
>> As Laurent said, if I were starting from scratch a new project I would
>> personally use the pyramid-cookiecutter-starter sqlalchemy and then rip out
>> what I didn’t need but only one part of that cookie cutter is the ORM. It
>> has several other features that you need to solve one way or another so
>> you’d at least want to know what you’re getting rid of. It is modular and
>> you can pick the layers you want.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/fd53e026-af8b-45ed-b4fe-df073e50f0e7n%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/fd53e026-af8b-45ed-b4fe-df073e50f0e7n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CANVFhUqwxWd-fOZ-qy2phhDkNkjhA3OscXXwh9Vdis%3DnH1B-tw%40mail.gmail.com.

Reply via email to