Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install execsql

How to install execsql

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install execsql
 Python 2.7Python 3.2Python 3.3
Windows (32-bit) Available View build log
Windows (64-bit) Available View build log
Mac OS X (10.5+) Available View build log
Linux (32-bit) Available View build log
Linux (64-bit) Available View build log
Lastest release
version on Jan 5th, 2011

execsql.py is a Python module and program that allows you to apply a SQL query script stored in a text file to an Access database. Special commands embedded in SQL comments also allow text and database queries to be sent from the script to the console or to text files (query output can be exported as CSV or tab-delimited text). The output of the last SQL query in the script can be automatically saved in a CSV file or routed to--and then viewed in--an Excel worksheet.


You can use the execsql program to:

  • Execute a complex query script that selects and summarizes data, and

System Message: WARNING/2 (<string>, line 15)

Bullet list ends without a blank line; unexpected unindent.

capture the output in a comma-separated-value (CSV) file. The CSV file can then be used as input to other software, including statistical, spreadsheet, and database applications. * Execute a query script that selects and summarizes data, and view the results directly in Excel. * Execute SQL Data Definition Language (DDL) and Data Manipulation Language (DML) commands, stored in a text file, to create database tables and alter data in the database. Using execsql and other tools such as batch files and the Windows task scheduler, these operations can be set up so that they occur automatically without the need for any interactive use of Access. * Execute "CREATE QUERY..." and "CREATE TEMPORARY QUERY..." DDL statements, which are not natively supported by Access. This feature allows you to maintain a standard set of queries, or task-specific queries, in a text file and easily add them to any Access database. Support for "CREATE TEMPORARY QUERY..." DDL is also important to allow non-trivial data summarization scripts. * Export data and write messages using metacommands embedded in SQL comments.


The execsql program used the Common Object Model (COM) to communicate with Access and Excel. Python does not include a standard library that supports COM, and so execsql uses Mark Hammond's pywin32 extension for Windows to provide COM support. A version of pywin32 compatible with your version of Python must be installed so that execsql can be used.


  • Script files can contain comments to document the purpose and operation of

System Message: WARNING/2 (<string>, line 46)

Bullet list ends without a blank line; unexpected unindent.

the SQL statements. * A 'CREATE TEMPORARY QUERY...' extension to Access (Jet) SQL is supported to facilitate writing complex scripts. * With the exception of the 'CREATE TEMPORARY QUERY...' statement, the execsql program does not parse or interpret SQL syntax in any way. The program recognizes a SQL statement as consisting of any sequence of non-comment lines that ends with a line ending with a semicolon. SQL syntax used in the script must conform to that recognized by the Jet database engine. * Only the results of the final query in the script will be saved as CSV or routed to Excel. If the final query includes the "CREATE TEMPORARY QUERY..." prefix, then no output will be produced regardless of any output specification that is provided on the command line. If the final query is a DDL command, or a DML command other than a SELECT, UNION, or TRANSFORM statement, the output may not be produced, or may be empty or meaningless.

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:10

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.