title: run a python file by calling from php file
body: <p>i have a php file through which i am sending variables to python file using:</p>
  
  <pre><code>    echo 
  shell_exec("C:/xampp/htdocs/Ai_Edutech_trial_project/eclipse_workspace
  /Project/dbConn.py '$sess'");
  </code></pre>
  
  <p>it is working fine and but only a very small portion of python file is getting executed. I want execute whole python file for it have code to insert data in db.</p>
  
  <p>This is my python file:</p>
  
  <pre><code>    import mysql.connector
      import numpy as np
      import sqlite3
      import sys
  
      conn= mysql.conector.connect
      (user="root",password="",host="localhost",database="videojs")
  
      conn_two= sqlite3.connect('videojs')
      c=conn_two.cursor() 
  
  
      def read_from_db():
  
         sess_id=sys.argv[1]
         print(sess_id)
  
         cursor_one = conn.cursor()
         cursor_one.execute("select time_arr from info where sess_id= '%s'" % 
         (sess_id))
         data=cursor_one.fetchone()
         cursor_two = conn.cursor()
         cursor_two.execute("select type from questions")
         data_two=cursor_two.fetchall()
         str_data_two = ''.join(map(str, data_two))
         split_data_two=str_data_two.replace(")
         ('","").replace("'","").split(',') 
         the_new_list = [x.split(',') for x in data]
         str_data = ''.join(map(str, the_new_list))
  
         split_data=str_data.replace(" ", "").strip('[]').split(',')
         i = 0
         while i &lt; len(split_data):
           print(split_data[i])   
           i += 1
  
         #Open the file
         fobj = open("one.srt")
         text = fobj.read().strip().split()
         quo_text= (', '.join("'" + item + "'" for item in text))
         add_list=[]
         i = 0
  
         while i &lt; len(split_data):
           print(split_data[i])
           if  split_data[i] in quo_text: #string in present in the text file
              print("matched")
              ind_text=text.index(split_data[i].replace("'",""))
              fix_max=ind_text+5
              fix_min=ind_text-5
              while ind_text &lt; fix_max:
                   print(text[ind_text]) 
                   add_list.append(text[ind_text])  
                   ind_text += 1
              while ind_text &gt; fix_min:
                   print(text[ind_text])
                   add_list.append(text[ind_text])    
                   ind_text -= 1 
  
      else:
              print("not matched" )    
      i += 1 
  
      database_list=[]
      i = 0
      while i &lt; len(split_data_two):
         print(split_data_two[i])
         if  split_data_two[i] in add_list: #string in present in the text 
             file
              print("matched")
              ind_text=add_list.index(split_data_two[i])
              database_list.append(add_list[ind_text])
         else:
               print("not matched" )    
         i += 1       
  
         sess= sess_id 
         cursor_three=conn.cursor()
         for elem in database_list:
            cursor_three.execute("INSERT INTO data(sess_id,list) VALUES 
            (%s,%s)",(sess,elem))
         conn.commit()  
  
         fobj.close()
  
  
     read_from_db()
  </code></pre>
  
  <p>But when i pass value from php file only this portion of file is being executed from python file</p>
  
  <pre><code>def read_from_db():
  
    sess_id=sys.argv[1]
    print(sess_id)
  </code></pre>
  
  <p>can someone please help me out..?</p>