Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with DB Creation with Pyramid and SQLite
    primarykey
    data
    text
    <p>I'm building the Pyramid wiki from <a href="http://docs.pylonsproject.org/projects/pyramid/1.0/tutorials/wiki2/" rel="nofollow">this</a> tutorial.</p> <p>Everything works fine, except when try to create a folder for my models instead of having them in the file models.py in the main folder.</p> <p>I created a models folder, added a <code>__init__.py</code> file to it, and a Page file with the content:</p> <pre><code>from sqlalchemy import Column from sqlalchemy import Integer from sqlalchemy import Text from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Page(Base): """ The SQLAlchemy declarative model class for a Page object. """ __tablename__ = 'pages' id = Column(Integer, primary_key=True) name = Column(Text, unique=True) data = Column(Text) def __init__(self, name, data): self.name = name self.data = data` </code></pre> <p>This doesn't work - I get a "can't find table named pages" error. This is my <code>models.py</code> file:</p> <pre><code>import transaction from sqlalchemy.exc import IntegrityError from sqlalchemy import Column from sqlalchemy import Integer from sqlalchemy import Text from sqlalchemy.orm import scoped_session from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base from zope.sqlalchemy import ZopeTransactionExtension DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) Base = declarative_base() from test.models.Page import Page </code></pre> <p>Now if I replace the last line with this, everything works:</p> <pre><code>class Page(Base): """ The SQLAlchemy declarative model class for a Page object. """ __tablename__ = 'pages' id = Column(Integer, primary_key=True) name = Column(Text, unique=True) data = Column(Text) def __init__(self, name, data): self.name = name self.data = data </code></pre> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload