简体   繁体   中英

simultaneous database access question (Mysql,Sqlite?)

My basic problem is that i am trying to have two python programs run simultaneously and have access to the same database table. I feel like this should have a simple solution but it has passed my by so far.

All my attempts at this have caused the database(sqlite) to be locked and the program falling over. i have tried being clever with the timing with how they programs run so that as one program opens the connection the other closes it, copying data from one database to another etc.. but this just gets horrible and messy very quickly and also a big goal in my design is that I would like to keep latency to an absolute minimum.

The basic structure is pictured below.

I should add too that program one - 'always running and adding to database' is in the milliseconds timeframe. Program two can be in the multiple seconds range. Obviously none of my solutions have been able to come close to that.

在此处输入图片说明

Any help, steps in the right direction or links to further reading is greatly appreciated!

Cheers

Although your title mentions MySQL, in your question you are only using sqlite. Now, sqlite is a perfectly capable database if you only have a single process accessing it, but it is not good for multiple simultaneous access. This is exactly where you need a proper database - like MySQL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM