On Mon, Dec 22, 2008 at 3:07 PM, Vadim Khaskel <[email protected]> wrote:
> Hello,
>
> it looks like I'm stuck and need a little help here....
>
> I'm here right now:
> http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons
>
> the last thing that worked out successfully was creation of the tables:
> paster setup-app development.ini
>
> Next, when tables are created in MySQL, I tried to do:
>
> mr_jones = Person()
> mr_jones.name = 'Mr Jones'
> meta.Session.save(mr_jones)
> meta.Session.commit()
>
> ... in python shell that I opened in myapp directory.
>
>>>> myp=Person()
>>>> myp.name="Mr Jones"
>>>> meta.Session.save(myp)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: 'NoneType' object has no attribute 'save'
>
> trying to fix situation Iimported:
>
>>>> from helloworld.model import *
>>>> from helloworld import meta
>
> still the same problem...
>
> thank you for help,
I think you haven't called init_model yet.
from myapp import model
from myapp.model import meta
import sqlalchemy as sa
engine = sa.create_engine("sqlite:///mydb.sqlite")
model.init_model(engine)
myp = model.Person()
myp.name = "Mr Jones"
meta.Session.save(myp)
When first imported, meta.Session is None. init_model() updates it
with a live session bound to the engine.
--
Mike Orr <[email protected]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---