global_connect is related to how a Table object is associated with a  
particular database connection.  you just say, global_connect 
('somedatabase') and all Tables that are attached to  
sqlalchemy.default_metadata will then talk to that database.

the session is something entirely different.  the create_session()  
function will give you a new Session regardless of the usage of  
global_connect.

if you would like to bind a Session to the actual engine used by the  
current default_metadata, which is typically not really needed since  
the Tables usually talk to the default_metadata's engine directly,  
you can do create_session(bind_to=sqlalchemy.default_metadata.engine).

I know that all sounds confusing.  heres the usual workflow:

        Session -> Mapper -> Table -> DynamicMetaData -> Engine -> database


On Jun 4, 2006, at 8:28 AM, Keith Edmunds wrote:

> Sorry if this is documented (I have looked). I'm using global_connect,
> but I can't figure out how to save new objects.
>
> The documentation says:
>
> --------------------------------------------------------------------
> mapper(User, users_table)
>
> # create a new User
> myuser = User()
> myuser.user_name = 'jane'
> myuser.password = 'hello123'
>
> [...]
>
> # create a Session and save them
>
> sess = create_session()
> sess.save(myuser)
> --------------------------------------------------------------------
>
> I can't figure out how to obtain the session when using global_connect
> (or maybe there is another way of saving objects under those
> circumstances?).
>
> Thanks
>
>
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users



_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to