title: Create and update SQLite db from python .exe-file (using cx_Freeze)
body: <p><em>Greetings! This is my first question here, after having used the forum for several years. I will do my best to follow the guidelines, please comment with improvement suggestions to my question.</em></p>
  <hr />
  <p>My program gathers info from the steamspy.com API in JSON strings. These are written into a SQLite database.</p>
  <p>The program runs with no problems directly from the <strong>.py</strong> file, however, I would like to be able to run and distribute my program as a single executable file.</p>
  <p>I havse used cx_Freeze to create an <strong>.exe</strong> file, but the program does not generate the SQLite database. I have searched extensively throughout this forum and the web for a solution, without any luck.</p>
  <p>Below I have pasted the code for my main program <strong>steamSpy.py</strong>:</p>
  <pre><code>input(&quot;Press Enter to continue...&quot;)
  
  import requests
  import time
  import sys
  import sqlite3
  import datetime
  
  unix=time.time()
  date = str(datetime.datetime.fromtimestamp(unix).strftime('%y-%m-%d'))
  conn = sqlite3.connect('steamDB.db') #Starts connection
  c = conn.cursor() #Starts cursor
  
  def create_table():
      c.execute('Create TABLE IF NOT EXISTS steamData(counter REAL, date REAL, name TEXT, developer TEXT, score_rank REAL, owners REAL, owners_variance REAL, players_forever REAL, players_forever_variance REAL, players_2weeks REAL, players_2weeks_variance REAL, average_forever REAL, average_2weeks REAL, median_forever REAL, median_2weeks REAL, ccu REAL, price REAL)')
  
  def dynamic_data_entry():
  #    score_rank = []
  #    owners = []
      c.execute(&quot;INSERT INTO steamData (counter, date, name, developer, score_rank , owners , owners_variance , players_forever , players_forever_variance , players_2weeks , players_2weeks_variance , average_forever , average_2weeks , median_forever , median_2weeks , ccu , price) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)&quot;,
                (counter, date, str(name)[2:-2], str(developer)[2:-2], str(score_rank)[1:-1], str(owners)[1:-1], str(owners_variance)[1:-1], str(players_forever)[1:-1], str(players_forever_variance)[1:-1], str(players_2weeks)[1:-1], str(players_2weeks_variance)[1:-1], str(average_forever)[1:-1], str(average_2weeks)[1:-1], str(median_forever)[1:-1], str(median_2weeks)[1:-1], str(ccu)[1:-1], str(price)[2:-2]))
      conn.commit()
  
  create_table()
  
  def read_from_db():
      c.execute(&quot;SELECT counter, date FROM steamData WHERE counter=1&quot;) #cursor is populated now * but nothing has happened
      data_read = c.fetchall()
      if any(date in s for s in data_read):
          c.close() #Ends connection
          conn.close()
          sys.exit('Caution! Data from current date is already present in the database... Ending process')
  
  #Check for updated data
  read_from_db()
  
  #Get data
  baseURL = &quot;http://steamspy.com/api.php?request=&quot;
  request = &quot;appdetails&amp;appid=&quot;
  codes = [&quot;570&quot;, &quot;518790&quot;, &quot;322920&quot;, &quot;253710&quot;]
  url = codes
  counter = 0
  for x in url: 
      counter = counter + 1
      response = requests.get(baseURL + request + x)
      data = response.json()
      name = [data[&quot;name&quot;]]
      developer = [data[&quot;developer&quot;]]
      score_rank = [data[&quot;score_rank&quot;]]
      owners = [data[&quot;owners&quot;]]
      owners_variance = [data[&quot;owners_variance&quot;]]
      players_forever = [data[&quot;players_forever&quot;]]
      players_forever_variance = [data[&quot;players_forever_variance&quot;]]
      players_2weeks = [data[&quot;players_2weeks&quot;]]
      players_2weeks_variance = [data[&quot;players_2weeks_variance&quot;]]
      average_forever = [data[&quot;average_forever&quot;]]
      average_2weeks = [data[&quot;average_2weeks&quot;]]
      median_forever = [data[&quot;median_forever&quot;]]
      median_2weeks = [data[&quot;median_2weeks&quot;]]
      ccu = [data[&quot;ccu&quot;]]
      price = [data[&quot;price&quot;]]
      
      #Write to database
      dynamic_data_entry()
      time.sleep(0.25)
  
  #Close connection
  c.close() #Ends connection
  conn.close() 
  
  
  print(&quot;Program finished.&quot;)
  </code></pre>
  <p>Next up is my code for the <strong>setup.py</strong> file:</p>
  <pre><code>from cx_Freeze import setup, Executable
  
  setup(name='steamSpy',
        version='0.2',
        description='Gather_data',
        executables=[Executable(&quot;steamSpy.py&quot;)])
  </code></pre>
  <p>This is most likely trivial info, but in case someone is in doubt, the executable can be created with one of the following lines in the command prompt:</p>
  <blockquote>
  <p>python setup.py build</p>
  <p>python setup.py bdist_msi</p>
  </blockquote>