SQLAlchemy + URL Dispatch Wiki Tutorial

425 views
Skip to first unread message

Ian McLoughlin

unread,
Apr 19, 2012, 7:41:46 AM4/19/12
to pylons...@googlegroups.com
I've tried simply to create an alchemy scaffold app, only changing the development.ini file to use a MySQL database.
I've created the database already, but it's empty - no tables.

Running pserve then i get an error because the database hasn't been setup.
It says to run this command in the directory containing development.ini
../bin/initialize_tutorial_db development.ini

But I don't have a bin directory in the parent directory (Pyramid had nothing to do with the parent directory.)
I do have a myapp/scripts/initializedb.py file, but running that directly cause relative import errors (which I think it should).
Obviously I'm meant to import that file somehow otherwise.

The github directory for the tutorial (https://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src) doesn't have the initializedb executable either.

Am I missing something?

Thanks,
Ian

Chris McDonough

unread,
Apr 19, 2012, 8:59:25 AM4/19/12
to pylons...@googlegroups.com

You need to run "$yourvirtualenv/bin/python setup.py develop"

There will be an "initialize_db" script thereafter in
"$yourvirtualenv/bin/initialize_db".

>
> Thanks,
> Ian
>
> --
> You received this message because you are subscribed to the Google
> Groups "pylons-devel" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-devel/-/FvDMo2wjdKAJ.
> To post to this group, send email to pylons...@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-devel...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-devel?hl=en.

Ian McLoughlin

unread,
May 2, 2012, 7:45:58 AM5/2/12
to pylons...@googlegroups.com
Thanks Chris,

I found that script.
Now I'm getting an error on running it:

$ initialize_pyramid-skeleton_db development.ini
...
sqlalchemy.exc.OperationalError: (OperationalError) (1170, "BLOB/TEXT column 'name' used in key specification without a key length") '\nCREATE TABLE models (\n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\tname TEXT, \n\tvalue INTEGER, \n\tPRIMARY KEY (id), \n\tUNIQUE (name)\n)\n\n' ()


Any advice?
Thanks again,
Ian

Feng Wang

unread,
May 8, 2012, 1:05:56 AM5/8/12
to pylons...@googlegroups.com
what ORM do you use? SqlAlchemy?

It seems that you should give a length property to the "name" column.

在 2012年5月2日星期三UTC+8下午7时45分58秒,Ian McLoughlin写道:

Ian McLoughlin

unread,
May 8, 2012, 4:43:06 AM5/8/12
to pylons...@googlegroups.com
Thanks Feng,

I changed this line in models.py:
name = Column(Text, unique=True)

to:
name = Column(String(255), unique=True)

I was just wondering if I was doing something wrong, or if it was a bug.
I'll change the model in any case.

Thanks for the help,
Ian

Feng Wang

unread,
May 9, 2012, 6:32:05 AM5/9/12
to pylons...@googlegroups.com
It's not a bug. If you use sqlite or Postgresql, it's OK. But for others ,you must provide a length to String, Integer, Numeric, etc.
Reply all
Reply to author
Forward
0 new messages