Thread: [SQLObject] how to use sqlmeta.idName?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <jpa...@gm...> - 2005-07-16 16:44:09
|
Hi!
Can someone tell me how to use sqlmeta.idName on my classes?
I'm working with a already running database so that the names of the
primary key columns are not just 'id', but 'id_name' where name is the
name of the table.
I tryied like this:
class Test(SQLObject):
connection =3D _con # connection string
sqlmeta.idName =3D 'id_test'
test =3D StringCol()
test =3D Test.select()
This gives me an error because it can't find test.id column..
Thanks in advance,
--
JP
|
|
From: Oleg B. <ph...@ma...> - 2005-07-18 07:17:11
|
On Sat, Jul 16, 2005 at 01:42:52PM -0300, Jo?o Paulo Fernandes Farias wrote: > class Test(SQLObject): > connection = _con # connection string > sqlmeta.idName = 'id_test' > test = StringCol() > > test = Test.select() > > This gives me an error because it can't find test.id column.. http://www.catb.org/~esr/faqs/smart-questions.html#beprecise OS? DB? Driver? SQLObject's version? Traceback? Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
|
From: <jpa...@gm...> - 2005-07-18 11:07:35
|
Sorry! I'm on windows XP SP 2 with python 2.4.1 and SQLObject from SVN (revision from two days ago). I'm using postgresql and psycopg. -- JP On 7/18/05, Oleg Broytmann <ph...@ma...> wrote: > On Sat, Jul 16, 2005 at 01:42:52PM -0300, Jo?o Paulo Fernandes Farias wro= te: > > class Test(SQLObject): > > connection =3D _con # connection string > > sqlmeta.idName =3D 'id_test' > > test =3D StringCol() > > > > test =3D Test.select() > > > > This gives me an error because it can't find test.id column.. >=20 > http://www.catb.org/~esr/faqs/smart-questions.html#beprecise >=20 > OS? DB? Driver? SQLObject's version? Traceback? >=20 > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > |
|
From: <jpa...@gm...> - 2005-07-18 11:09:34
|
And the traceback:
Traceback (most recent call last):
File "D:/projetos/pontoa2-py/pessoa.py", line 67, in ?
for estado in estados:
File "c:\Python24\Lib\site-packages\sqlobject\sresults.py", line
147, in __iter__
return conn.iterSelect(self)
File "c:\Python24\Lib\site-packages\sqlobject\dbconnection.py", line
359, in iterSelect
select, keepConnection=3DFalse)
File "c:\Python24\Lib\site-packages\sqlobject\dbconnection.py", line
680, in __init__
self.dbconn._executeRetry(self.rawconn, self.cursor, self.query)
File "c:\Python24\Lib\site-packages\sqlobject\dbconnection.py", line
293, in _executeRetry
return cursor.execute(query)
psycopg.ProgrammingError: ERROR: column estado.id does not exist
SELECT estado.id, estado.uf, estado.nome FROM estado WHERE 1 =3D 1
--
JP
On 7/18/05, Jo=E3o Paulo Fernandes Farias <jpa...@gm...> wrote:
> Sorry!
>=20
> I'm on windows XP SP 2 with python 2.4.1 and SQLObject from SVN
> (revision from two days ago). I'm using postgresql and psycopg.
>=20
> --
> JP
>=20
> On 7/18/05, Oleg Broytmann <ph...@ma...> wrote:
> > On Sat, Jul 16, 2005 at 01:42:52PM -0300, Jo?o Paulo Fernandes Farias w=
rote:
> > > class Test(SQLObject):
> > > connection =3D _con # connection string
> > > sqlmeta.idName =3D 'id_test'
> > > test =3D StringCol()
> > >
> > > test =3D Test.select()
> > >
> > > This gives me an error because it can't find test.id column..
> >
> > http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
> >
> > OS? DB? Driver? SQLObject's version? Traceback?
> >
> > Oleg.
> > --
> > Oleg Broytmann http://phd.pp.ru/ ph...@ph....=
ru
> > Programmers don't die, they just GOSUB without RETURN.
> >
>
|
|
From: Oleg B. <ph...@ma...> - 2005-07-18 11:14:44
|
On Mon, Jul 18, 2005 at 08:09:27AM -0300, Jo?o Paulo Fernandes Farias wrote:
> psycopg.ProgrammingError: ERROR: column estado.id does not exist
That's strange because Igot a different error:
File "./test_idName.py", line 5, in ?
class Test(SQLObject):
File "./test_idName.py", line 7, in Test
sqlmeta.idName = 'id_test'
NameError: name 'sqlmeta' is not defined
Where does your sqlmeta come from?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|
|
From: <jpa...@gm...> - 2005-07-18 11:23:05
|
Are you using the SVN version?
If I try it like that:
class Test(SQLObject):
_idName=3D'test_id'
connection =3D _con
test =3D StringCol()
It will work, but gives me a warning:
D:/projetos/pontoa2-py/pessoa.py:15: DeprecationWarning: '_idName' is
deprecated; please set the 'idName' attribute in sqlmeta instead
class Test(SQLObject):
So, I'm trying to use the sqlmeta, but I don't know how to use it. =3D(
--
JP
On 7/18/05, Oleg Broytmann <ph...@ma...> wrote:
> On Mon, Jul 18, 2005 at 08:09:27AM -0300, Jo?o Paulo Fernandes Farias wro=
te:
> > psycopg.ProgrammingError: ERROR: column estado.id does not exist
>=20
> That's strange because Igot a different error:
>=20
> File "./test_idName.py", line 5, in ?
> class Test(SQLObject):
> File "./test_idName.py", line 7, in Test
> sqlmeta.idName =3D 'id_test'
> NameError: name 'sqlmeta' is not defined
>=20
> Where does your sqlmeta come from?
>=20
> Oleg.
> --
> Oleg Broytmann http://phd.pp.ru/ ph...@ph...
> Programmers don't die, they just GOSUB without RETURN.
>
|
|
From: Oleg B. <ph...@ph...> - 2005-07-18 11:49:00
|
On Mon, Jul 18, 2005 at 08:22:50AM -0300, Jo?o Paulo Fernandes Farias wrote:
> Are you using the SVN version?
But of course!
> So, I'm trying to use the sqlmeta, but I don't know how to use it. =(
The correct way is:
class Test(SQLObject):
class sqlmeta:
idName = 'id_test'
test = StringCol()
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|
|
From: <jpa...@gm...> - 2005-07-18 11:53:37
|
Thanks! That was the answer I was looking for! =3DD -- JP On 7/18/05, Oleg Broytmann <ph...@ph...> wrote: > On Mon, Jul 18, 2005 at 08:22:50AM -0300, Jo?o Paulo Fernandes Farias wro= te: > > Are you using the SVN version? >=20 > But of course! >=20 > > So, I'm trying to use the sqlmeta, but I don't know how to use it. =3D( >=20 > The correct way is: >=20 > class Test(SQLObject): > class sqlmeta: > idName =3D 'id_test' > test =3D StringCol() >=20 > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > |
|
From: Oleg B. <ph...@ph...> - 2005-07-18 12:24:37
|
On Mon, Jul 18, 2005 at 08:53:30AM -0300, Jo?o Paulo Fernandes Farias wrote:
> That was the answer I was looking for! =D
Did it help?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|
|
From: <jpa...@gm...> - 2005-07-18 12:29:51
|
Sure! Helped a lot. Thanks again. -- JP On 7/18/05, Oleg Broytmann <ph...@ph...> wrote: > On Mon, Jul 18, 2005 at 08:53:30AM -0300, Jo?o Paulo Fernandes Farias wro= te: > > That was the answer I was looking for! =3DD >=20 > Did it help? >=20 > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > |