title: Using Alembic API from inside application code
body: <p>I am using SQLite as an application file format (see <a href="http://www.sqlite.org/appfileformat.html">here</a> for why you would want to do this) for my PySide-based desktop application. That is, when a user uses my app, their data is saved in a single database file on their machine. I am using the SQLAlchemy ORM to communicate with the databases.</p>
  
  <p>As I release new versions of the application, I may modify the database schema. I don't want users to have to throw away their data every time I change the schema, so I need to migrate their databases to the newest format. Also, I create temporary databases a lot to save subsets of the data for use with some external processes. I want to create these databases with alembic so they are tagged with the proper version.</p>
  
  <p>I have a few questions:</p>
  
  <ul>
  <li><p>Is there a way to call alembic from inside my Python code? I think it's weird to have to use <code>Popen</code> to a pure Python module, but the docs just use alembic from the command line. Mainly, I need to change the database location to wherever the user's database is located. </p></li>
  <li><p>If that's not possible, can I specify a new database location from the command line without editing the .ini file? This would make calling alembic through <code>Popen</code> not a big deal.</p></li>
  <li><p>I see that alembic keeps its version information under a simple table called <code>alembic_version</code>, with one column called <code>version_num</code> and a single row specifying the version. Can I add an <code>alembic_version</code> table to my schema and populate it with the latest version when I create new databases so there is no overhead? Is that even a good idea; should I just use alembic to create all databases?</p></li>
  </ul>
  
  <p>I have alembic working great for the single database I use to develop with in my project's directory. I want to use alembic to conveniently migrate and create databases in arbitrary locations, preferably through some sort of Python API, and not the command line. This application is also frozen with cx_Freeze, in case that makes a difference.</p>
  
  <p>Thanks!</p>