The Change Log


  1. When ~mosql.db.Database goes nest, only commit the changes after exit the first with.


  1. Fix the connection leaking issue.


  1. Fix the Python 2 support.


Thanks for the contribution from Toki Tseng and Pinkoi.

  1. Enhance multithreading and multiprocessing support.


This version is totally made by Tzu-ping Chung (uranusjr). Thanks for his contribution.

  1. Supports Python 3!
  2. Combined the doctests and nose tests by the sphinx-nose which is also made by uranusjr.
  3. Fixed the bug which caused the instllation on Windows failed.
  4. Works better on Windows.


The Majoy Changes

  1. The Database supports to keep connection open.
  2. The Database is thread-safe now.
  3. The insert() supports multi-value.
  4. The build_where() translates x IN () into FALSE.
  5. The build_where() allows to use pair as key to include operator.
  6. The mosql.util.Statement.format ignores false – in bool context – clause argument.
  7. The mosql.util.Statement.format raises TypeError if there is any unused clause argument.
  8. Added mosql.util.Query.enable_echo() to echo the SQL it builds.

Check details in Database or select().

The Minor Changes

  1. Added dot(), as_(), asc(), desc(), subq(), and in_operand().
  2. All of the patch modules in The Patches for Non-standard SQLs have a .patch() method to apply the patch again.
  3. The identifier() was split into identifier(), identifier_as(), and identifier_dir().
  4. The identifier() supports to use pair to include table and column name; and
  5. The identifier_as() and identifier_dir() also supports to use pair to include alias or direction.
  6. Renamed OptionError to DirectionError.
  7. The delimit_identifier(), allowed_operators, and allowed_directions don’t allow to disable anymore. Use raw instead.
  8. The deprecated modules in /deprecated will be removed in 0.11.
  9. Refined all the documentation.


  1. Now qualifier() supports to encode unicode into utf-8 str automatically.


  1. Added MySQL-specific UPDATE FOR and LOCK IN SHARE MODE for select().
  2. Added PostgreSQL-specific FOR, OF and NOWAIT for select().
  3. Fixed select can’t use from_ as argument.
  4. Added and changed the arguments of Clause.


  1. Fixed the regression that causes converting int fails. #33


  1. columns now is the alias of select.
  2. Fixed the complain of inserting with empty dict.
  3. Added mosql.sqlite for better SQLite support.
  4. Added mosql.query.replace().
  5. Renamed mosql.statement to mosql.stmt.
  6. Added mosql.func for basic SQL functions supprt.
  7. Support using pair (2-tuple) to build AS statement.
  8. Support subquery perfectly.

Thanks Tzu-ping Chung (uranusjr) contributed the PRs (#27, #15, #14, and #12) which bring the improvement 2, 6, 7 and 8.

Thanks lucemia contributed the PRs (#19, #13) which bring the improvement 3 and 4.

And, thanks PyCon TW and your sprint event in 2013 Oct! :)


  1. Fixed the compatibility of mosql.db with Python 2.6. Thanks Aminzai.


  1. Added mosql.util.and_().


  1. mosql.util.or_() should add paren.


  1. Improved the compatibility with MySQLdb.


  1. Added the Travis CI badge. Thanks for the contribution from xKerman.
  2. Added Make DB API 2.0 Easier to Use — mosql.db.
  3. Arranged the examples.


  1. Nothing but the change of the docs.



Some of the modules are deprecated after v0.6, check /deprecated for more information.

  1. Deprecated some of the modules. Check /deprecated for detail.
  2. Made the mosql.util.Clause and mosql.util.Statement better.
  3. Added the mosql.util.Query.
  4. Added the mosql.query, mosql.statement, mosql.clause, and mosql.chain for the instances in common use.


  1. Fixed the compatibility of mosql.util with types which inherit the basic types.


  1. Fixed the compatibility of mosql.json with mosql.result.Model.


  1. The uses mosql.result.Model.arrange_by to save the changes on column squashed.
  2. The mosql.result.Model.clear() is also improved.
  3. Improved the program of loading result set.
  4. The or mosql.result.Model.where() returns None if no row is returned.


  1. Improved the code of mosql.result.Model.
  2. Added
  3. Added mosql.result.Model.add().
  4. Added mosql.result.Model.clear().
  5. The mosql.result.Model.perform() now supports to call procedure, execute SQL with parameter and executemany.
  6. Fixed the compatibility with MySQL.


  1. Improved the code of mosql.result.Model.
  2. Added mosql.result.Model.squash_all for 1:1 table.
  3. Added mosql.result.Model.rows() for iterating the rows.
  4. The rows in mosql.result.Model can be accessed by row index now.
  5. Added mosql.result.Model.getcur() for customizing cursor.
  6. The mosql.result.Model.pop() returns the row it poped now.
  7. The mosql.result.Model.row() and mosql.result.Model.col() are removed.


  1. Improved memory usage of mosql.result.Model.arrange().
  2. MoSQL supports to use native escape functions now (via mosql.psycopg2_escape or mosql.MySQLdb_escape).


  1. Fixed a bug of mosql.result.Model.append().



The versions after v0.2 are a new branch and it does not provide backward-compatibility for v0.1.x.

  1. The mosql.result is totally rewritten, and does not provide the backward-compatibility. See the doc for more info.
  2. The mosql.common is renamed as
  3. The mosql.ext is removed.
  4. The uses set instead of pairs_or_columns.
  5. The supports “on duplicate key update” now.
  6. The uses * if user pass None in.
  7. MoSQL passed all of the injection tests from sqlmap on value and identifier with PostgreSQL and MySQL.


  1. The mosql.util is faster (1.35x~1.7x) after rewriting.
  2. The mosql.util also supports to delimit the identifier (for avoiding injection from identifier),
  3. use arbitrary SQL statements by mosql.util.raw,
  4. and customize parameter name of prepared statement by mosql.util.param now.
  5. The mosql.ext is deprecated now, please use mosql.common instead.


  1. This version refined the mosql.mysql.
  2. MoSQL with PostgreSQL or MySQL passed all of the injection tests from sqlmap.


  1. Fixed the dumped value of datetime, date and time.


  1. This version reverted the #3 changes in the previous version.
  2. By default, the mosql.result.Model now orders the result set by nothing.


  1. Added the mosql.mysql.
  2. The now respects the arguments from users.
  3. The group_by now uses the value of identify_by, by default.
  4. The order_by stops using the value of identify_by.


  1. Added the mosql.json.
  2. Added the mosql.result.Model.customize().
  3. The Model now can use attributes to access data.
  4. The Model now allows user to customize insert, select, update and delete.
  5. It respects the column_names when do a select.
  6. Fixed the wrong sql without specifying identify_by.
  7. Fixed the SQL dumped with None. (issue #1)