librelist archives

« back to archive

Sessions using flask-sqlalchemy?

Sessions using flask-sqlalchemy?

From:
Nicholas Earl
Date:
2014-09-18 @ 19:55
Hey there,

I'm trying to get in the habit of using sqlalchemy with flask, but I can't
seem to understand the analogue of the session['logged_in'] portion of the
flask tutorial. How would I do this using sqlalchemy? It seems I don't need
to do the app.config.update stuff (I mean, I haven't seen that being done
in the flask-sqlalchemy tutorials). Should I use the db.session object?

Thanks for any help,
Nick

Re: [flask] Sessions using flask-sqlalchemy?

From:
Daniel Neuhäuser
Date:
2014-09-18 @ 22:46
Session in the context of Flask itself means something completely 
different from session in the context of SQLAlchemy. In other words your 
questions don't really make any sense.

I suggest you carefully read the documentation of Flask and SQLAlchemy to 
figure out what a session is in each context and what it's used for.

On 18 Sep 2014, at 21:55, Nicholas Earl <nchlsearl@gmail.com> wrote:

> Hey there,
> 
> I'm trying to get in the habit of using sqlalchemy with flask, but I 
can't seem to understand the analogue of the session['logged_in'] portion 
of the flask tutorial. How would I do this using sqlalchemy? It seems I 
don't need to do the app.config.update stuff (I mean, I haven't seen that 
being done in the flask-sqlalchemy tutorials). Should I use the db.session
object?
> 
> Thanks for any help,
> Nick

Re: [flask] Sessions using flask-sqlalchemy?

From:
Matthias Urlichs
Date:
2014-09-19 @ 06:30
Hi,

Daniel Neuhäuser:
> Session in the context of Flask itself means something completely 
different from session in the context of SQLAlchemy. In other words your 
questions don't really make any sense.
> 
> I suggest you carefully read the documentation of Flask and SQLAlchemy 
to figure out what a session is in each context and what it's used for.
> 
Or, for novice users, simply take one of the flask-sqlalchemy sample
programs as your starting point, and forget about the underpinnings
(at first; you'll probably need them later. Or not. Depending on what
you're doing).

-- 
-- Matthias Urlichs

Re: [flask] Sessions using flask-sqlalchemy?

From:
Jacek Nosal
Date:
2014-09-19 @ 06:48
Hi,

Actually I'd rather advice on learning ORM component before rushing into
flask-sqlalchemy integration library.

Sqlalchemy is powerful but requires a lot of work and has a lot of
philosophies to understand, e.g data mapper pattern instead of active
record on ORM being just no layer build on top of Sqlalchemy Core (another
being Elixir for example).

Jacek

2014-09-19 8:30 GMT+02:00 Matthias Urlichs <matthias@urlichs.de>:

> Hi,
>
> Daniel Neuhäuser:
> > Session in the context of Flask itself means something completely
> different from session in the context of SQLAlchemy. In other words your
> questions don't really make any sense.
> >
> > I suggest you carefully read the documentation of Flask and SQLAlchemy
> to figure out what a session is in each context and what it's used for.
> >
> Or, for novice users, simply take one of the flask-sqlalchemy sample
> programs as your starting point, and forget about the underpinnings
> (at first; you'll probably need them later. Or not. Depending on what
> you're doing).
>
> --
> -- Matthias Urlichs
>

Re: [flask] Sessions using flask-sqlalchemy?

From:
Matthias Urlichs
Date:
2014-09-19 @ 07:18
Hi,

Jacek Nosal:
> Actually I'd rather advice on learning ORM component before rushing into
> flask-sqlalchemy integration library.
> 
That's no contradiction. If you want to use sqlalchemy well, you need to
understand what and how to do with it, no question. But the session part 
is already handled and, unless you have "interesting" requirements, I'd
advise to just use what flask-SQLA provides, and focus on the more
interesting parts.

Data Mapper vs. Active Record is just one part of it. However, the
distinction isn't nearly as black-and-white as some Pattern people
insist. :-P

> Sqlalchemy is powerful but requires a lot of work and has a lot of
> philosophies to understand, e.g data mapper pattern instead of active
> record on ORM being just no layer build on top of Sqlalchemy Core (another
> being Elixir for example).
> 
The second half of this sentence isn't. 

--
-- Matthias Urlichs

Re: [flask] Sessions using flask-sqlalchemy?

From:
Jacek Nosal
Date:
2014-09-19 @ 07:53
:)

ok maybe i rushed with my answer. But i personally like to know internals
of the things I'm using. It's probably a good idea to stick with
flask-sqlalchemy for common use cases and focus on advanced stuff when
working on larger projects i guess.


2014-09-19 9:18 GMT+02:00 Matthias Urlichs <matthias@urlichs.de>:

> Hi,
>
> Jacek Nosal:
> > Actually I'd rather advice on learning ORM component before rushing into
> > flask-sqlalchemy integration library.
> >
> That's no contradiction. If you want to use sqlalchemy well, you need to
> understand what and how to do with it, no question. But the session part
> is already handled and, unless you have "interesting" requirements, I'd
> advise to just use what flask-SQLA provides, and focus on the more
> interesting parts.
>
> Data Mapper vs. Active Record is just one part of it. However, the
> distinction isn't nearly as black-and-white as some Pattern people
> insist. :-P
>
> > Sqlalchemy is powerful but requires a lot of work and has a lot of
> > philosophies to understand, e.g data mapper pattern instead of active
> > record on ORM being just no layer build on top of Sqlalchemy Core
> (another
> > being Elixir for example).
> >
> The second half of this sentence isn't.
>
> --
> -- Matthias Urlichs
>