Monday, May 28, 2007

How to compile pysqlite for Windows

If you are reading this page that means you know that pysqlite is and probably need updated version of this python extension for windows compiled against newer version of SQLite. Why would anyone need it? Perhaps because of fixed bugs or SQLAlchemy complaining that you need a better SQLite version as it happened in my case.

Original instructions are available for discontinued MS Toolkit Compiler at and these are for MinGW compiler. First of all you need to install MinGW somewhere and preferably add directory with gcc.exe into %PATH%. Then unpack pysqslite sources, edit setup.cfg to look like this:


That means sqlite3/ directory should contain additional includes and libraries required to compile the extension. These are sqlite3.dll and sqlite3.h available at SQLite downloads from and archives. Unpack them into sqlite3/subdirectory of already unpacked pysqlite source. Now issue: build --compiler=mingw32

If everything compiles Ok patch to carry sqlite3.dll inside to avoid messages about missing .dll

--- pysqlite-2.3.3/ Sun Jan 14 02:56:12 2007
+++ pysqlite-2.3.3/ Mon May 28 15:59:05 2007
@@ -109,7 +109,9 @@
+ glob.glob("doc/*.txt") \
+ glob.glob("doc/*.css")),
- glob.glob("doc/code/*.py"))]
+ glob.glob("doc/code/*.py")),
+ ("Lib/site-packages/pysqlite2",
+ ["sqlite3/sqlite3.dll"])]

py_modules = ["sqlite"]
setup_args = dict(

Then build an installer to save your work for the future. I saved mine at bdist_wininst


  1. Hi, i follow your steps buut i cant realize that, i got a custom sqlite3.dll file that i want to convert in a single standalone pysqlite.pyd, do you think thats possible ?