[SQLObject] _idName not working for me.
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ben S. <sch...@pr...> - 2005-02-08 15:14:09
|
I'm running Python 2.4 with SQLObject 0.6.1, psycopg-1.1.18 and Postgres 8.0 under Windows Server 2003. Loading an existing class definition from the database (like the Person example) works just fine until I wanna use a different name for my id. For example: With the following table structure: CREATE TABLE entity ( entity_id serial NOT NULL, url varchar, CONSTRAINT entity_pkey PRIMARY KEY (entity_id) ) WITH OIDS; ALTER TABLE entity OWNER TO postgres; I get the following result: >>> class Entity(SQLObject): ... _idName='entityId' ... _fromDatabase = True ... 1/Pool : ACQUIRE pool=[] 1/QueryAll: SELECT pg_catalog.pg_get_constraintdef(oid) as condef FROM pg_catalog.pg_constraint r WHERE r.conrelid = 'entity'::regclass AND r.contype = 'f' 1/Pool : RELEASE (implicit, autocommit=True) pool=[] 1/COMMIT : auto 1/Pool : ACQUIRE pool=[] 1/QueryAll: SELECT pg_index.indisprimary, pg_catalog.pg_get_indexdef(pg_index.indexrelid) FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index AS pg_index WHERE c.relname = 'entity' AND c.oid = pg_index.indrelid AND pg_index.indexrelid = c2.oid AND pg_index.indisprimary 1/Pool : RELEASE (implicit, autocommit=True) pool=[] 1/COMMIT : auto 1/Pool : ACQUIRE pool=[] 1/QueryAll: SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod), a.attnotnull, (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d WHERE d.adrelid=a.attrelid AND d.adnum = a.attnum) FROM pg_catalog.pg_attribute a WHERE a.attrelid ='entity'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum 1/Pool : RELEASE (implicit, autocommit=True) pool=[] 1/COMMIT : auto Traceback (most recent call last): File "<interactive input>", line 1, in ? File "C:\Python24\Lib\site-packages\sqlobject\main.py", line 179, in __new__ newClass.addColumnsFromDatabase() File "C:\Python24\Lib\site-packages\sqlobject\main.py", line 505, in addColumnsFromDatabase for columnDef in conn.columnsFromSchema(cls._table, cls): File "C:\Python24\Lib\site-packages\sqlobject\postgres\pgconnection.py", line 187, in columnsFromSchema colClass, kw = self.guessClass(t) File "C:\Python24\Lib\site-packages\sqlobject\postgres\pgconnection.py", line 201, in guessClass return col.StringCol, {'length': int(t[t.index('(')+1:-1])} ValueError: substring not found >>> I've also tried _idName = 'entity_id' not being certain if the name mangling occurs here or not.and got the exact same results. Otherwise - interesting product and I'm really excited about using it for me present development. But I gotta be able to suck in my existing database schema rather than define it from python. thanx & later, Ben Scherrey |