Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I execute a python script to assign my database in postgres, I get this Error !!

"AttributeError 'psycopg2._psycopg.cursor' object attribute 'execute' is read-only "

def ma_fonction(d):
    # connexion à la base de données
    conn = psycopg2.connect("dbname = 'test3' user = 'postgres' host = 'localhost' password = 'postgres'")
    cur = conn.cursor()
    for n in d :
        cur.execute = ("""
        PDATE douar SET distance_route = %s,  distance_piste = %s, distance_ecole = %s, distance_college = %s, distance_sante = %s, distance_souk=%s WHERE id =%s
        """,
        d[n]['route'] / 1000.0,
        d[n]['piste'] / 1000.0 ,
        d[n]['ecole'] / 1000.0,
        d[n]['college'] / 1000.0,
        d[n]['sante'] / 1000.0,
        d[n]['souk'] / 1000.0
        )
    conn.commit()
    print(commit) 

Any solution plz !!

share|improve this question

Remove the =. It should be:

cur.execute("""UPDATE douar SET dist...)
share|improve this answer
    
Thank u Nathan W :) – Anass Ing Jun 20 '13 at 10:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.