Locks in SQLAlchemy

Joined
Aug 28, 2015
Messages
1
Reaction score
0
Hi,

I am using SQLAlchemy to do transactions into PosgreSQL db using Python application.
I don't know how to use locks in SQLAlchemy.

Anybody can help me to use locks in SQLAlchemy.

I am facing a problem as follows,

While running two instances of a an application parallel, it tries to insert rows into a same table. Sometimes I am getting error of duplicate primary key. Can I resolve this using lock concept?


Best Regards,
Suji
 
Joined
Feb 19, 2016
Messages
2
Reaction score
0
1) If you are using postgres database you want to run the both instance with out the error of primary key use serial data type for the table.
2) External locking procedure :

conn = engine.connect()
conn.execute("LOCK TABLES Pointer WRITE")
#do stuff with conn
conn.execute("UNLOCK TABLES")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top