어떤 오타도 용서해주십시오. SQLite 이외의 데이터베이스에 대한 경험이 많지 않습니다. 데이터베이스를 두 번째 데이터베이스에 연결하고 모든 테이블에서 쿼리 할 수있는 SQLite에서 수행 할 작업을 복제하려고합니다. SQLite로 SQLAlchemy를 사용하지 않았습니다.SQLAlchemy가 postgres_fdw와 연결된 Postgres 테이블을 찾지 못했습니다.
저는 Win7/54에서 SQLAlchemy 1.0.13, Postgres 9.5 및 Python 3.5.2 (Anaconda 사용)와 함께 작업하고 있습니다. postgres_fdw를 사용하여 두 개의 데이터베이스 (로컬 호스트에 있음)를 연결하고 보조 데이터베이스에서 몇 개의 테이블을 가져 왔습니다. PgAdminIII의 SQL과 psycopg2를 사용하는 Python을 사용하여 연결된 테이블을 성공적으로 쿼리 할 수 있습니다. (로부터 테이블을
insp = reflection.Inspector.from_engine(engine)
print(insp.get_table_names())
및 첨부 된 테이블이 나열되지 않은 : SQLAlchemy의와 나는 시도했다 :
# Same connection string info that psycopg2 used
engine = create_engine(conn_str, echo=True)
class TestTable(Base):
__table__ = Table('test_table', Base.metadata,
autoload=True, autoload_with=engine)
# Added this when I got the error the first time
# test_id is a primary key in the secondary table
Column('test_id', Integer, primary_key=True)
및 오류 얻을 : 다음
sqlalchemy.exc.ArgumentError: Mapper Mapper|TestTable|test_table could not
assemble any primary key columns for mapped table 'test_table'
을 나는 시도 기본 데이터베이스가 표시됩니다). 내가 성취하려는 일을 할 수있는 방법이 있습니까?
감사합니다. – RunDeep