Hi folks! I'm creating a app with the following structure: project/ main.py manage.py -- users/ -- -- __init__.py -- -- models.py <http://dpaste.org/auwJi/> In manage.py I use the db.create_all() to create the database, but things do not work out. When importing User, I get the following error: File "/home/italo/.virtualenvs/env/lib/python2.7/site-packages/sqlalchemy/ext/declarative.py", line 1069, in _as_declarative if not table.c.contains_column(c): AttributeError: 'str' object has no attribute 'c' Any idea what could it be? -- "A arrogância é a arma dos fracos." =========================== Italo Moreira Campelo Maia Bacharel em Ciência da Computação - UECE Desenvolvedor WEB e Desktop (Java, Python, Lua) Coordenador do Pug-CE ----------------------------------------------------- http://www.italomaia.com/ http://twitter.com/italomaia/ http://eusouolobomau.blogspot.com/ ----------------------------------------------------- Turtle Linux 9.10 - http://tiny.cc/blogturtle910 Turtle Linux 10.10 - http://bit.ly/cEw4ET ===========================
On Sep 13, 2011, at 6:30 AM, Italo Maia wrote: > In manage.py I use the db.create_all() to create the database, but things do not work out. When importing User, I get the following error: > > File "/home/italo/.virtualenvs/env/lib/python2.7/site-packages/sqlalchemy/ext/declarative.py", line 1069, in _as_declarative > if not table.c.contains_column(c): > AttributeError: 'str' object has no attribute 'c' > > Any idea what could it be? Could you please provide a stack trace, and the part of your code where the model for User is defined? Cheers, -- Alex
Model is defined here: http://dpaste.org/auwJi/ Complete stack trace: http://dpaste.org/rSeXb/ 2011/9/13 Alex Morega <alex@grep.ro> > > On Sep 13, 2011, at 6:30 AM, Italo Maia wrote: > > > In manage.py I use the db.create_all() to create the database, but things > do not work out. When importing User, I get the following error: > > > > File > "/home/italo/.virtualenvs/env/lib/python2.7/site-packages/sqlalchemy/ext/declarative.py", > line 1069, in _as_declarative > > if not table.c.contains_column(c): > > AttributeError: 'str' object has no attribute 'c' > > > > Any idea what could it be? > > Could you please provide a stack trace, and the part of your code where the > model for User is defined? > > Cheers, > -- Alex > > -- "A arrogância é a arma dos fracos." =========================== Italo Moreira Campelo Maia Bacharel em Ciência da Computação - UECE Desenvolvedor WEB e Desktop (Java, Python, Lua) Coordenador do Pug-CE ----------------------------------------------------- http://www.italomaia.com/ http://twitter.com/italomaia/ http://eusouolobomau.blogspot.com/ ----------------------------------------------------- Turtle Linux 9.10 - http://tiny.cc/blogturtle910 Turtle Linux 10.10 - http://bit.ly/cEw4ET ===========================
It seems missing '__tablename__ = "users"' caused the problem. Stacktrace did not help me at all : / 2011/9/13 Italo Maia <italo.maia@gmail.com> > Model is defined here: http://dpaste.org/auwJi/ > Complete stack trace: http://dpaste.org/rSeXb/ > > > 2011/9/13 Alex Morega <alex@grep.ro> > >> >> On Sep 13, 2011, at 6:30 AM, Italo Maia wrote: >> >> > In manage.py I use the db.create_all() to create the database, but >> things do not work out. When importing User, I get the following error: >> > >> > File >> "/home/italo/.virtualenvs/env/lib/python2.7/site-packages/sqlalchemy/ext/declarative.py", >> line 1069, in _as_declarative >> > if not table.c.contains_column(c): >> > AttributeError: 'str' object has no attribute 'c' >> > >> > Any idea what could it be? >> >> Could you please provide a stack trace, and the part of your code where >> the model for User is defined? >> >> Cheers, >> -- Alex >> >> > > > -- > "A arrogância é a arma dos fracos." > > =========================== > Italo Moreira Campelo Maia > Bacharel em Ciência da Computação - UECE > Desenvolvedor WEB e Desktop (Java, Python, Lua) > Coordenador do Pug-CE > ----------------------------------------------------- > http://www.italomaia.com/ > http://twitter.com/italomaia/ > http://eusouolobomau.blogspot.com/ > ----------------------------------------------------- > Turtle Linux 9.10 - http://tiny.cc/blogturtle910 > Turtle Linux 10.10 - http://bit.ly/cEw4ET > =========================== > -- "A arrogância é a arma dos fracos." =========================== Italo Moreira Campelo Maia Bacharel em Ciência da Computação - UECE Desenvolvedor WEB e Desktop (Java, Python, Lua) Coordenador do Pug-CE ----------------------------------------------------- http://www.italomaia.com/ http://twitter.com/italomaia/ http://eusouolobomau.blogspot.com/ ----------------------------------------------------- Turtle Linux 9.10 - http://tiny.cc/blogturtle910 Turtle Linux 10.10 - http://bit.ly/cEw4ET ===========================
flaskext-sqlalchemy docs says it's a optional attribute tough. 2011/9/13 Italo Maia <italo.maia@gmail.com> > It seems missing '__tablename__ = "users"' caused the problem. Stacktrace > did not help me at all : / > > > 2011/9/13 Italo Maia <italo.maia@gmail.com> > >> Model is defined here: http://dpaste.org/auwJi/ >> Complete stack trace: http://dpaste.org/rSeXb/ >> >> >> 2011/9/13 Alex Morega <alex@grep.ro> >> >>> >>> On Sep 13, 2011, at 6:30 AM, Italo Maia wrote: >>> >>> > In manage.py I use the db.create_all() to create the database, but >>> things do not work out. When importing User, I get the following error: >>> > >>> > File >>> "/home/italo/.virtualenvs/env/lib/python2.7/site-packages/sqlalchemy/ext/declarative.py", >>> line 1069, in _as_declarative >>> > if not table.c.contains_column(c): >>> > AttributeError: 'str' object has no attribute 'c' >>> > >>> > Any idea what could it be? >>> >>> Could you please provide a stack trace, and the part of your code where >>> the model for User is defined? >>> >>> Cheers, >>> -- Alex >>> >>> >> >> >> -- >> "A arrogância é a arma dos fracos." >> >> =========================== >> Italo Moreira Campelo Maia >> Bacharel em Ciência da Computação - UECE >> Desenvolvedor WEB e Desktop (Java, Python, Lua) >> Coordenador do Pug-CE >> ----------------------------------------------------- >> http://www.italomaia.com/ >> http://twitter.com/italomaia/ >> http://eusouolobomau.blogspot.com/ >> ----------------------------------------------------- >> Turtle Linux 9.10 - http://tiny.cc/blogturtle910 >> Turtle Linux 10.10 - http://bit.ly/cEw4ET >> =========================== >> > > > > -- > "A arrogância é a arma dos fracos." > > =========================== > Italo Moreira Campelo Maia > Bacharel em Ciência da Computação - UECE > Desenvolvedor WEB e Desktop (Java, Python, Lua) > Coordenador do Pug-CE > ----------------------------------------------------- > http://www.italomaia.com/ > http://twitter.com/italomaia/ > http://eusouolobomau.blogspot.com/ > ----------------------------------------------------- > Turtle Linux 9.10 - http://tiny.cc/blogturtle910 > Turtle Linux 10.10 - http://bit.ly/cEw4ET > =========================== > -- "A arrogância é a arma dos fracos." =========================== Italo Moreira Campelo Maia Bacharel em Ciência da Computação - UECE Desenvolvedor WEB e Desktop (Java, Python, Lua) Coordenador do Pug-CE ----------------------------------------------------- http://www.italomaia.com/ http://twitter.com/italomaia/ http://eusouolobomau.blogspot.com/ ----------------------------------------------------- Turtle Linux 9.10 - http://tiny.cc/blogturtle910 Turtle Linux 10.10 - http://bit.ly/cEw4ET ===========================