Can I run python with php accessing the same mysql database/table at the same time?

Discussion in 'Hosting Talk & Reviews' started by poomrokc, Nov 1, 2016.

  1. poomrokc

    poomrokc New Member

    1
    0
    Nov 1, 2016
    Hello , sorry for the confusing title ,I do not speak english as my first language.(and also sorry if the topic does not fit here)


    Problem background: I just want to create a website as a competitive program grader for my school. Like complie and run source code on the server. So below is my idea and i would like some help/suggestions before i do it,I still don't know if this will work.


    Mysql usage:


    The problem one is that i would use one of the table as my user-submission queue.When user submit a code, I first put it in this table(i suppose it put the new row in the bottom of the table?) .


    Python program usage:


    I would run a 24/7 program on my server that check every 10 second  if the queue table is not empty, just run the grading process(I know how to do it) and then pop it off the queue.Then check again.


    PHP usage:


    When a person submit code, i will use php to put it on the queue table,but it may be the same time my python program is popping something off the queue table too. This is where I get confuse whether it will work or not.(Other usage of the php is just things about web interface which I had done before and know what to do)


    So,would this idea even work? Will it break my server or something?As a competitive programmer guy I don't know much snd will greatly appreciate any help from u guys. :)


    Thank you very much.
     
  2. graeme

    graeme Active Member

    171
    41
    Nov 20, 2013
    With a real relational database you would not even need to ask. Transactions take care of this.


    With MySQL, you are probably OK if the tables were created with a recent version of MySQL. Check whether they are InnoDB or MyIASM tables. If they are InnoDB it is definitely OK. If they are MyIASM I am not sure - it may be OK if it is just a single row, if there are any foreign keys pointing to it from another table them MyIASM will not be OK.