Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3320918
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:00:02+00:00 2026-05-17T23:00:02+00:00

I got a problem with PostGreSQL 8.4 and tables reflection. My metadata object seems

  • 0

I got a problem with PostGreSQL 8.4 and tables reflection. My metadata object seems to be ok (it has foreign keys, primary keys, every columns and tables). But when I try to associate an object to an another one through a Foreign key, I get : “sqlalchemy.exc.ProgrammingError: (ProgrammingError) can’t adapt type ‘EventParameters’ ‘INSERT INTO event (“.

I’m using SQLAlchemy 0.6.3 (psycopg2 2.2.1) and PostGreSQL 8.4.5

Here, my code :


#! /usr/bin/env python 

from sqlalchemy import MetaData, create_engine 
from sqlalchemy.orm import mapper, sessionmaker 

class EventParameters(object): 
    pass 

class Event(object): 
    pass 

engine = create_engine('postgresql://postgres:toto@127.0.0.1:5432/renass') 
metadata = MetaData() 
metadata.reflect(bind=engine) 
Session = sessionmaker(bind=engine) 
session = Session() 
mapper(EventParameters, metadata.tables['eventparameters']) 
mapper(Event, metadata.tables['event']) 

ep = EventParameters() 
ep.publicid = 'test' 

e = Event() 
e.publicid = 'test' 
e.eventparametersid=ep 

session.add(e) 
session.commit()

and my database :


CREATE TABLE EventParameters ( 
    id SERIAL PRIMARY KEY, 
    publicID varchar(255) UNIQUE NOT NULL, 
    description varchar(255), 
    creationInfo_agencyID varchar(64), 
    creationInfo_agencyURI varchar(255), 
    creationInfo_author varchar(128), 
    creationInfo_authorURI varchar(255), 
    creationInfo_creationTime time, 
    creationInfo_version varchar(64) 
); 

CREATE TABLE Event ( 
    id SERIAL PRIMARY KEY, 
    eventParametersID integer NOT NULL REFERENCES EventParameters(id), 
    publicID varchar(255) UNIQUE NOT NULL, 
    preferredOriginID integer, 
    preferredMagnitudeID integer, 
    preferredFocalMechanismID integer, 
    type EventType, 
    typeCertainty EventTypeCertainty, 
    creationInfo_agencyID varchar(64), 
    creationInfo_agencyURI varchar(255), 
    creationInfo_author varchar(128), 
    creationInfo_authorURI varchar(255), 
    creationInfo_creationTime time, 
    creationInfo_version varchar(64) 
);

It seems that SQLAlchemy don’t recognize the attribute “eventparametersid” as a relationship …

Thank you in advance
Fabien

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:00:03+00:00Added an answer on May 17, 2026 at 11:00 pm

    To make your code working you should change the mapper invocation for the Event class to include the mapping between the two classes

    mapper(Event, metadata.tables['event'], properties={
        'eventparameters': relation(EventParameters)
    })
    

    then use that column to assign the EventParameters instance

    ep = EventParameters()
    ep.publicid = 'test'
    
    e = Event()
    e.publicid = 'test'
    e.eventparameters = ep
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a problem similar to,but subtly different from, that described here (Loading assemblies
I have got the following problem since the server has safe mode turned on,
Ok so got through my last problem with the difference between Postgresql and SQLite
I have started a jetty server in my remote server. But I got problem
I set my editor use the whitespace only, but I got problem with the
I've got a problem with my CoreData, but I'm sure I'm doing something wrong
Got a problem with ADOMD.NET 8.0, SQL2008 and our app. It isn't giving us
I got a problem like this (this is html/css menu): Eshop | Another eshop
I've got a problem here with an MSI deployment that I'm working on (using
I've got a problem with inheritance and generics. This is the code that illustrates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.