6

I'm new to SQLAlchemy, but I'm trying to use it to create and fill a database for a personal project. I've set pool_timeout to 43200 (twelve hours), but I'm still getting socket timeouts.

engine = sqlalchemy.create_engine(
            'postgresql+pg8000://gdwatson:pass@localhost/dbname',
            pool_timeout=43200)
db.tables.meta.drop_all(bind=engine)
db.tables.meta.create_all(bind=engine)

conn = engine.connect()
dataset = build_dataset()
conn.execute(db.tables.mytable.insert(),
             dataset)
conn.close()

I end up getting socket.timeout: timed out after a good deal of processing time, but probably under an hour and certainly under two. It's actually three levels deep-- while handling the timeout exception another occurred, and then when handling that one yet another occurred. (Perhaps this is the library retrying?) The exception occurs in conn.execute, and I'm at a loss as to how to prevent it.

A search hasn't turned up anything informative. I am using Python 3.1 and SQLAlchemy 0.6.1, for what it's worth.

1
  • I ended up slicing dataset into 1000-entry chunks and inserting it one chunk at a time. That worked around the problem, even if it's a bit uglier. Commented Aug 29, 2010 at 5:58

1 Answer 1

2

I don't know if this is the recommended method, but you could periodically send a SELECT 1 statement and ensure the connection isn't idle.
You could also look into this for some guidance

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.