title: Inserting function inside other function in python
body: <p>i have small application written in tkinter, python. I would like  to choose txt file by clicking button in tkinter and automaticaly send it to my SQL database.
  For this moment i have function responsible for choosing a file from my disc and printing my txt file in console:</p>
  
  <pre><code>def OpenFile():
      name = askopenfilename(initialdir="",
                         filetypes =(("Text File", "*.txt"),("All Files","*.*")),
                         title = "Choose a file."
                         )
      print(name)
      #Using try in case user types in unknown file or closes without choosing a file.
      try:
          with open(name,'r') as UseFile:
              print(UseFile.read())
      except:
          print("No file exists")
  </code></pre>
  
  <p>And function responsible for sending to SQL looks this way (txt file is inserted inside function):</p>
  
  <pre><code>def Tabela():
      with open("pom1.txt") as infile:
          for line in infile:
              data = line.split("\t")
              print(data)
              query = ("INSERT INTO Pomiary_Obwod_90(Pomiar_x, Pomiar_y, Pomiar_z) VALUES"
                   "(" + data[1] + ", " + data[2] + ", " + data[3] + ");")
              cursor.execute(query, data)
              con.commit()
     return
  </code></pre>
  
  <p>Does anybody knows what could i do to connect those two functions? The idea is to choose txt file from function OpenFile() and then application should send it automatically to database.</p>