пока проблему решил так:
в pgconnection.py заменил
def columnsFromSchema(self, tableName, soClass):
keyQuery = """
SELECT pg_catalog.pg_get_constraintdef(oid) as condef
FROM pg_catalog.pg_constraint r
WHERE r.conrelid = %s::regclass AND r.contype = 'f'"""
colQuery = """
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 =%s::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum"""
primaryKeyQuery = """
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 = %s
AND c.oid = pg_index.indrelid
AND pg_index.indexrelid = c2.oid
AND pg_index.indisprimary
"""
primaryKeyQueryMySchema = """
SELECT
pg_index.indisprimary,
pg_indexes.indexdef
FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index AS pg_index, pg_indexes
WHERE c.relname = '%(tableNameOnly)s'
AND c.oid = pg_index.indrelid
AND pg_index.indexrelid = c2.oid
AND pg_index.indisprimary
AND pg_indexes.tablename = '%(tableNameOnly)s'
AND pg_indexes.schemaname = '%(schemaname)s'
AND pg_catalog.pg_get_indexdef(pg_index.indexrelid) = pg_indexes.indexdef;
"""
keyData = self.queryAll(keyQuery % self.sqlrepr(tableName))
keyRE = re.compile(r"\((.+)\) REFERENCES (.+)\(")
keymap = {}
for (condef,) in keyData:
match = keyRE.search(condef)
if match:
field, reftable = match.groups()
keymap[field] = reftable.capitalize()
if '.' in tableName:
schemaname, tableNameOnly = tableName.split('.')
else:
schemaname, tableNameOnly = 'public', tableName
sql = primaryKeyQueryMySchema%{'schemaname':schemaname, 'tableNameOnly':tableNameOnly}
#primaryData = self.queryAll(primaryKeyQuery % self.sqlrepr(tableName))
primaryData = self.queryAll(sql)
primaryRE = re.compile(r'CREATE .*? USING .* \((.+?)\)')
primaryKey = None
for isPrimary, indexDef in primaryData:
match = primaryRE.search(indexDef)
assert match, "Unparseable contraint definition: %r" % indexDef
assert primaryKey is None, "Already found primary key (%r), then found: %r" % (primaryKey, indexDef)
primaryKey = match.group(1)
assert primaryKey, "No primary key found in table %r" % tableName
if primaryKey.startswith('"'):
assert primaryKey.endswith('"')
primaryKey = primaryKey[1:-1]
colData = self.queryAll(colQuery % self.sqlrepr(tableName))
results = []
if self.unicodeCols:
client_encoding = self.queryOne("SHOW client_encoding")[0]
for field, t, notnull, defaultstr in colData:
if field == primaryKey:
continue
colClass, kw = self.guessClass(t)
if self.unicodeCols and colClass is col.StringCol:
colClass = col.UnicodeCol
kw['dbEncoding'] = client_encoding
kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
kw['dbName'] = field
kw['notNone'] = notnull
if defaultstr is not None:
kw['default'] = self.defaultFromSchema(colClass, defaultstr)
elif not notnull:
kw['default'] = None
if keymap.has_key(field):
kw['foreignKey'] = keymap[field]
results.append(colClass(**kw))
return results
после этого заработало
>>> import sqlobject
>>> from sqlobject import *
>>> connection_string = “postgres://postgres@localhost/t1”
>>> connection = sqlobject.connectionForURI(connection_string)
>>> sqlobject.sqlhub.processConnection = connection
>>> hub = connection.transaction()
>>> class Author(SQLObject):
… class sqlmeta:
… table = ‘boo.author’
… fromDatabase = True
…
>>> class Author1(SQLObject):
… class sqlmeta:
… table = ‘author’
… fromDatabase = True
…
>>> Author.sqlmeta.columns
{'login': <SOStringCol login not null>, ‘password’: <SOStringCol password not null>, ‘name’: <SOStringCol name not null>}
>>> Author(login='login', password='password', name='name')
<Author 1L login='login' password='password' name='name'>
>>> Author.select()
<SelectResults at -4883e954>
>>> Author.select()
<SelectResults at -4883ea14>
>>> Author.select()
<SelectResults at -4883e954>
>>> Author.select()
<SelectResults at -4883e874>
>>> print Author.select()
SELECT boo.author.id, boo.author.login, boo.author.password, boo.author.name FROM boo.author WHERE 1 = 1 LIMIT 5
>>> l = list(Author.select())
>>> l
>>> Author1(login='login', password='password', name='name')
<Author1 1L login='login' password='password' name='name'>
>>> list(Author1.select())
PS SQLObject-0.8.2-py2.4.egg, debian lenny
через catwalk тоже работатет