librelist archives

« back to archive

Flask and Postgresql Stored Procedures/Functions

Flask and Postgresql Stored Procedures/Functions

From:
Zanzibar Hercules
Date:
2014-10-24 @ 05:24
Hi - I’m a newbie to Flask after having spent some time with Django. I’ve
learnt the hard way that Django just doesn’t cut for me. My intention is to
build a high performance Python web app that can be extended easily with a
increase in the number of concurrent users and evolution of requirements.
I’m thinking of using Flask  to keep my front-end and business rules layer
free from bloat and as thin as possible. I want to focus my efforts on
optimising the database back-end while leveraging stored procedures or
functions in a Postgresql database.

I need to call Postgresql stored procedures/functions from Flask and do not
want to use an ORM - I’ve looked at the stored procedure/function calling
capabilities in Flask-MoreSQL and SQLAlchemy but do not have the experience
to know if these are the best performing data access layers out there. Any
guidance would be appreciated. Many thanks.

Re: [flask] Flask and Postgresql Stored Procedures/Functions

From:
김현준
Date:
2014-10-24 @ 06:19
Greetings.

SQLAlchemy is not only ORM but also provides a flexible and powerful core,
allowing you access SQL primitives. If you have a function named
some_custom_function in your PostgreSQL database, you can just call it via
attribute of sqlalchemy.func like:
conn.execute(select([func.some_custom_function(param)])).

I'm working with SQLAlchemy and Flask at work, and the application supports
hundreds of thousands users every day. Based on my experiences, SQLAlchemy
is very stable and performs well.

Hope these links help:
- http://docs.sqlalchemy.org/en/rel_0_9/#sqlalchemy-core
- http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#functions
- http://flask.pocoo.org/docs/0.10/patterns/sqlalchemy/

2014-10-24 14:24 GMT+09:00 Zanzibar Hercules <zan.herc@gmail.com>:

> Hi - I’m a newbie to Flask after having spent some time with Django. I’ve
> learnt the hard way that Django just doesn’t cut for me. My intention is to
> build a high performance Python web app that can be extended easily with a
> increase in the number of concurrent users and evolution of requirements.
> I’m thinking of using Flask  to keep my front-end and business rules layer
> free from bloat and as thin as possible. I want to focus my efforts on
> optimising the database back-end while leveraging stored procedures or
> functions in a Postgresql database.
>
> I need to call Postgresql stored procedures/functions from Flask and do
> not want to use an ORM - I’ve looked at the stored procedure/function
> calling capabilities in Flask-MoreSQL and SQLAlchemy but do not have the
> experience to know if these are the best performing data access layers out
> there. Any guidance would be appreciated. Many thanks.
>

Re: [flask] Flask and Postgresql Stored Procedures/Functions

From:
Zanzibar Hercules
Date:
2014-10-24 @ 10:13
Many thanks for confirming, Yoloseem - that is exactly the guidance (based
on experience) I was looking for. I appreciate it.

On 24 October 2014 17:19, 김현준 <yoloseem@gmail.com> wrote:

> Greetings.
>
> SQLAlchemy is not only ORM but also provides a flexible and powerful core,
> allowing you access SQL primitives. If you have a function named
> some_custom_function in your PostgreSQL database, you can just call it
> via attribute of sqlalchemy.func like:
> conn.execute(select([func.some_custom_function(param)])).
>
> I'm working with SQLAlchemy and Flask at work, and the application
> supports hundreds of thousands users every day. Based on my experiences,
> SQLAlchemy is very stable and performs well.
>
> Hope these links help:
> - http://docs.sqlalchemy.org/en/rel_0_9/#sqlalchemy-core
> - http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#functions
> - http://flask.pocoo.org/docs/0.10/patterns/sqlalchemy/
>
> 2014-10-24 14:24 GMT+09:00 Zanzibar Hercules <zan.herc@gmail.com>:
>
>> Hi - I’m a newbie to Flask after having spent some time with Django. I’ve
>> learnt the hard way that Django just doesn’t cut for me. My intention is to
>> build a high performance Python web app that can be extended easily with a
>> increase in the number of concur rent users and evolution of requirements.
>> I’m thinking of using Flask  to keep my front-end and business rules layer
>> free from bloat and as thin as possible. I want to focus my efforts on
>> optimising the database back-end while leveraging stored procedures or
>> functions in a Postgresql database.
>>
>> I need to call Postgresql stored procedures/functions from Flask and do
>> not want to use an ORM - I’ve looked at the stored procedure/function
>> calling capabilities in Flask-MoreSQL and SQLAlchemy but do not have the
>> experience to know if these are the best performing data access layers out
>> there. Any guidance would be appreciated. Many thanks.
>>
>
>