|
1 | 1 |  |
2 | 2 |
|
3 | | -SQLite/CE: A transactional, relational database engine for Windows CE |
4 | | ---------------------------------------------------------------------- |
| 3 | +SQLite/CE: A transactional relational database for Windows CE |
| 4 | +------------------------------------------------------------- |
5 | 5 |
|
6 | | -**SQLite/CE** is a port of SQLite 2.8.17 to Windows CE 2.0 and later, allowing these early handhelds to support complex relational databases and SQL queries for any use case. SQLite/CE can power data-driven applications on your device as a standalone DLL or can be used to directly manage personal databases with, **SQLite/CEdit** the bundled advanced query editor. The complete SQLite/CE package currently targets only Handheld PCs (including 480x240 devices,) but Palm-size and Pocket PC support is planned in future releases. |
| 6 | +**SQLite/CE** is a complete software suite built around a port of SQLite 2.8.17 to Windows CE, allowing Handheld, Palm-size and Pocket PCs running CE 2.0 and later to support full-fledged relational databases and complex queries. SQLite/CE is componentized into separate libraries and executables, meaning it can be used to drive data-driven applications as a standalone DLL or used for end-to-end data management using the native query editor, **SQLite/CEdit**. |
7 | 7 |
|
8 | | -SQLite/CE's components, particularly the graphical front-end applications in the distribution, were written with the assistance of Claude Opus 4.5. While the process was heavily guided and managed, be aware that there could still be strange bugs or oversights lurking within the code of these pre-release versions. A complete human rewrite is planned in the future once the full feature set is cemented and implemented. |
| 8 | +# Distribution |
9 | 9 |
|
10 | | -# Overview |
11 | | -The standard SQLite/CE distribution is a set of three applications: the core library `SQLiteCE.dll`, and two front-end applications; the advanced query editor **SQLite/CEdit** and the **SQLite/CE Test** harness. SQLite/CE's front-end applications currently only support Handheld PCs (including 480x240 devices,) support for Palm-sized and Pocket PCs is planned in future releases. |
| 10 | +SQLite/CE consists of three core binaries: `SQLiteCE.dll`, the ported SQLite library; `SQLiteCEdit.exe`, the native query editor; and `SQLiteCETest.exe`, the optional test harness that can be used to validate SQLite/CE functionality on your platform. |
12 | 11 |
|
13 | 12 | ## Library |
14 | | -The SQLite/CE library is a full-fledged port of SQLite to the Windows CE operating system, supporting ACID-compliant transactions and constructs such as temporary tables, constraints, triggers and indexes. SQLite/CE's SQL interpreter has full SQL-92 support with the ability to handle complex queries including compound queries and subqueries. Like standard SQLite, the SQLite/CE library implements a simple C API that can be easily used by front-end applications. |
15 | 13 |
|
16 | | -## Query editor |
17 | | -**SQLite/CEdit** is an advanced query editor that allows users to design, create, manage and query SQLite 2.x databases directly on their devices. SQLite/CEdit maximizes screen utilization by splitting query and result views into distinct "panes" that can be switched between by graphical controls or keyboard shortcuts, with results displayed either as exportable plaintext or (in future releases) interactive grids. SQLite/CEdit in its current form is mainly intended for technical users as a database design and testing tool. |
| 14 | +The core SQLite/CE library `SQLiteCE.dll` is a fully functional port of SQLite 2.8 to the Windows CE operating system, implementing a serverless, self-contained database engine that supports ACID-compliant transactions and advanced constructs like temporary tables, views, constraints, triggers and indexes. SQLite/CE's SQL interpreter is mostly compliant with the SQL-92 standard and provides most essential features, including support for compound queries and subqueries. For application developers, SQLite/CE carries over SQLite's straightforward C API that can be easily integrated with other applications and redistributed alongside them. |
18 | 15 |
|
19 | | -SQLite/CEdit executes multi-line queries statement-by-statement and supports various modes of execution; all at once, only highlighted text, or only the statement currently under the cursor position, allowing users to bundle multiple distinct queries into a single file and run only what they need. The editor interface is designed to maximize convenience in workflow for many different kinds of user, with an interface that is both graphical and keyboard-driven depending on preference. Most major functions have keyboard shortcuts implemented. |
| 16 | +## SQLite/CEdit |
20 | 17 |
|
21 | | -SQLite/CEdit can be used to import and export data from CSV format and can even import data from Windows CE in-memory databases. The editor's CSV export tools are capable of exporting individual tables or entire databases as collections of multiple CSVs. |
| 18 | +SQLite/CE includes a native query editor, **SQLite/CEdit**, that allows users to design, create, manage and query SQLite 2.x-formatted databases directly from a Windows CE device with a number of notable advanced features. SQLite/CEdit intends to be more than just a Pocket Access alternative, with functionality approaching that of desktop SQL database management tools. |
22 | 19 |
|
23 | | -## Test harness |
24 | | -SQLite/CE includes a simple "test harness" application that exercises various functions of the SQLite/CE core library. This application is mainly used and maintained for developer debugging, but is included in the distribution as a demonstration of SQLite's more advanced capabilities that also allows users to validate untested systems. |
| 20 | +### Interface |
| 21 | + |
| 22 | +SQLite/CEdit pays considerable attention to workflow efficiency with a goal of implementing "tap-free" paths for most essential operations through universal and context-specific keyboard shortcuts. |
| 23 | + |
| 24 | +To maximize screen utilization, SQLite/CEdit uses a switchable pane-based UI with three distinct full-screen modes: |
| 25 | + |
| 26 | +#### Query Editor |
| 27 | + |
| 28 | +SQLite/CEdit's query editor pane allows users to prepare and execute queries in-memory or on a database file. The editor supports the following essential features: |
| 29 | +- Find/replace with wrap-around search |
| 30 | +- Adjustable font scaling |
| 31 | +- Line numbering with logical line support |
| 32 | +- Flexible execution modes: full script, single-statement or selection |
| 33 | +- Ability to abort long-running queries |
| 34 | + |
| 35 | +#### Result Viewer |
| 36 | + |
| 37 | +SQLite/CEdit's result viewer is bimodal and capable of displaying output in either tab-separated plaintext or interactive grid format based on user preference, both of which also provide status feedback on query runtime and rows returned. Users can select and copy individual lines/rows with ease or directly export entire result sets to .txt and .csv formats for use with other applications. |
| 38 | + |
| 39 | +#### Schema Explorer |
| 40 | + |
| 41 | +SQLite/CEdit includes the Schema Explorer, which allows users to graphically explore a database's structure and content through a tree view, with a number of notable features: |
| 42 | +- Advanced view mode showing rowcounts and size approximation for individual tables |
| 43 | +- Object dropping (with confirmation) |
| 44 | +- DDL export for single objects or an entire database schema |
| 45 | +- Interactive grid/cell editing for tables for data maintenance |
| 46 | + |
| 47 | +### Configuration and persistence |
| 48 | + |
| 49 | +SQLite/CEdit implements user-configurable options that persist across sessions using the Windows registry, which can also be cleared by the user for uninstallation or reset. Leveraging the same functionality, SQLite/CEdit also remembers recent databases and query files to allow you to quickly resume work or access frequently used scripts and datasets. |
| 50 | + |
| 51 | +### Data migration |
| 52 | + |
| 53 | +SQLite/CEdit includes tools to migrate data in and out of SQLite databases in a variety of formats: |
| 54 | +- Tables export to CSV or SQL `INSERT` statement sets |
| 55 | +- Database clone and export to collections of CSVs |
| 56 | +- In-memory database instantiation to file |
| 57 | +- Import from .CSV and Windows CE database formats with type inference |
| 58 | + |
| 59 | +## SQLite/CE Test |
| 60 | + |
| 61 | +SQLite/CE includes a simple "test harness" application that exercises various features of the SQLite library. This application is tailored to the needs of the project's development and is not rigorously complete, but is nonetheless provided as something potentially useful to those who wish to validate or test the performance of the ported library on their device. |
25 | 62 |
|
26 | 63 | # Installation |
27 | | -SQLite/CE is currently distributed in loose binary form and its components must be manually copied and placed on your device: |
28 | | -- `SQLiteCE.dll` must reside in the `\Windows` directory on the handheld |
29 | | -- `SQLiteCEdit.exe` and `SQLiteCETest.exe` can be placed anywhere to user preference |
30 | | - |
31 | | -# Limitations (what SQLite/CE is not, and cannot do) |
32 | | -## SQLite 2.x is not 3.x |
33 | | -SQLite/CE is a port of SQLite 2.8, which was chosen both for its relative simplicity and also smaller memory footprint for CE devices, which often have 8 MB or less of available memory for applications. While this has allowed for SQLite/CE to achieve its goals, it comes with a number of limitations: |
34 | | -- **No multi-row `INSERT`S**: Each `INSERT` must be a distinct statement. |
35 | | -- **No support for adding columns to tables after creation** using `ALTER TABLE ADD COLUMN`. Adding or removing columns from a table requires you to create a new table and manually migrate data. |
36 | | -- **No `IF EXISTS`:** Checking if an object exists must be done by the external application by querying the `sqlite_master` table. |
37 | | -- **No common table expressions** such as `WITH` |
38 | | -- **No window functions** such as `OVER` or `PARTITION BY` |
39 | | -- **No JSON functions or full-text search** |
40 | | -- **No user-defined collation** |
41 | | -- **Concurrency:** SQLite 2.x supports multiple readers **OR** a single writer, but not both at the same time, unlike SQLite 3.x. Windows CE itself introduces further concurrency limitations that are discussed in the next section. |
42 | | -- **Database compatibility:** SQLite 2.x cannot work with databases created by newer versions of SQLite, as 3.x significantly overhauled the SQLite database file format. If you would like to work with SQLite 3.x databases on your handheld, you will need to dump and reimport the data to a 2.x-formatted database on another system first. |
43 | | -- **Encoded BLOBs:** SQLite 2.x officially supports unstructured Binary Large Objects (BLOBs) as a data type, but very inefficiently as it stores all data internally as ASCII text, which requires BLOBs to be encoded and decoded from ASCII during operation. Because of this, SQLite 2.x BLOBs incur slight overhead, and cannot be directly operated on in queries and comparisons. |
44 | | -- **Unicode support:** SQLite 2.x is not encoding-aware and effectively ASCII-only due to unpredictable behavior of its string and sorting functions with accented and other UTF-8 characters, though it may still technically be able to store them. |
45 | | -- **Row limits:** SQLite 2.x stores ROWIDs as signed 32-bit integers, meaning each table can "only" store up ~ 2,147,483,647 unique rows, which will cause `INSERT` operations to fail after that limit is reached. Given the memory limitations of most CE devices, however, this is merely a theoretical ceiling. |
46 | | -- **Database size limits:** SQLite 2.x uses 32-bit signed integers to identify data pages, putting an upper limit of ~2 GB on database size, which could be potentially limiting on higher-end CE devices with large storage cards. |
47 | | - |
48 | | -## Windows CE is not Windows NT |
49 | | -Windows CE, while incredibly advanced for a 1990s embedded operating system, has a number of fundamental limitations that impact how SQLite/CE can function. Some key limitations include: |
50 | | -- **Concurrency (CE 2.0 only):** Prior to the introduction of `LockFileEx()` in Windows CE 2.11, Windows CE was not capable of supporting shared files among multiple applications, even read-only usage. To protect against corruption, SQLite/CE for CE 2.0 devices instead implements a primitive no-op locking scheme, and allows only one application to access the database at a time. |
51 | | -- **File handling**: Windows CE has a path limit of 260 characters maximum. |
| 64 | + |
| 65 | +SQLite/CE is currently distributed as loose binaries, which can be found in the [project releases](https://github.com/nfinit/SQLiteCE/releases) section by clicking the latest tag and navigating to the end of the description. Release tags can also be used to download the source code snapshot for a specific release. |
| 66 | + |
| 67 | +To install the full SQLite/CE distribution: |
| 68 | +- Place `SQLiteCE.dll` in the `\Windows` directory of your device |
| 69 | +- Place the binaries `SQLiteCEdit.exe` and `SQLiteCETest.exe` in a location of your choosing, such as a directory in `\Program Files` or on your storage card. |
| 70 | +- Create shortcuts on the desktop and Start menu (`\Windows\Programs`) as desired |
| 71 | + |
| 72 | +# Notes and limitations |
| 73 | + |
| 74 | +SQLite/CE is based on SQLite 2.8, which is quite old (from 2004,) but also much simpler and lighter on memory than newer 3.x releases, while still being much more powerful than the majority of extant database management systems available for Windows CE. But while SQLite/CE can still be very useful, it's important to keep its limitations in mind. |
| 75 | + |
| 76 | +## Comparison to SQLite 3.x |
| 77 | + |
| 78 | +Although essentially similar, SQLite 3.x implements a growing number of new features that are not supported in 2.8. A broad overview of the most significant changes can be found in [this official overview of SQLite 3.0](https://sqlite.org/version3.html), with the most important being: |
| 79 | + |
| 80 | +### Language compatibility |
| 81 | + |
| 82 | +Modern versions of SQLite 3 have introduced many new language enhancements over |
| 83 | +the past 20 years. While SQLite 2's SQL implementation is fairly complete, you |
| 84 | +will likely encounter limitations from time to time, such as lack of support |
| 85 | +for multi-row `INSERT` statements. A more comprehensive exploration of language |
| 86 | +limitations (and workarounds) will be published in the future. |
| 87 | + |
| 88 | +### Format compatibility |
| 89 | + |
| 90 | +SQLite 3.x databases **cannot** be read by SQLite 2.8 or SQLite/CE, and vice versa. If you wish to directly work with database files created on your handheld on another system with a more modern version of SQLite, you must export the data and re-import it to a new SQLite 3.x database. SQLite/CEdit has a number of features that can make this process less painful, with the ability to export entire databases into collections of CSVs, as well as extract complete object definitions (DDL) that can then be loaded into a new database. |
| 91 | + |
| 92 | +### BLOB support |
| 93 | + |
| 94 | +SQLite 2.8 stores *all* data internally as ASCII text, including Binary Large Objects (BLOBs). This approach, while officially supported, requires developers working with BLOB data to explicitly encode and decode it to and from SQLite's BLOB format before it can be stored or read, using the API functions `sqlite_encode_binary()` and `sqlite_decode_binary()`, respectively. Compared to SQLite 3's fully native BLOB support, the SQLite 2 encoded BLOB format is slightly more inefficient, and can incur a 1-2% storage penalty. |
| 95 | + |
| 96 | +### Collation |
| 97 | + |
| 98 | +SQLite 2.8 does not support user-defined collation for sorting and comparison, |
| 99 | +and always performs these operations using byte-order comparison, which does |
| 100 | +not allow for locale-aware (e.g. international characters) or case-insensitive |
| 101 | +comparison. |
| 102 | + |
| 103 | +### Unicode support |
| 104 | + |
| 105 | +SQLite 2.8 is capable of storing and operating on UTF-8 characters, but is |
| 106 | +not itself encoding-aware, instead treating everything as single-byte ASCII text |
| 107 | +in all cases. This causes unpredictable behavior with core SQLite components |
| 108 | +such as sorting, string (e.g. `upper()`, `lower()`) and pattern matching functions |
| 109 | +(such as the SQL `LIKE` operator) that will often fail to work consistently with unicode characters. |
| 110 | +For this reason, SQLite/CE databases should be treated as strictly ASCII-only in |
| 111 | +almost all cases. |
| 112 | + |
| 113 | +### Rowcount and size limits |
| 114 | + |
| 115 | +Though still far beyond the capabilities of most Windows CE devices, SQLite 2.8 |
| 116 | +has hard limits on rowcounts and database sizes due to its reliance on 32-bit |
| 117 | +signed integers to identify rows and data pages. A single table can store a |
| 118 | +theoretical maximum of around 2,147,483,647 rows, and single databases are |
| 119 | +limited to ~ 2 GB in size. |
| 120 | + |
| 121 | +### Concurrency |
| 122 | + |
| 123 | +SQLite 2.8 can support multiple readers or one writer, but not both at the same |
| 124 | +time as write operations require database-level locking, meaning prolonged |
| 125 | +write operations can cause significant contention with consuming applications. |
| 126 | + |
| 127 | +## Limitations of Windows CE |
| 128 | + |
| 129 | +### Concurrency |
| 130 | + |
| 131 | +Under Windows CE 2.0, SQLite/CE can only support *one user at any time*, due to |
| 132 | +lacking `LockFileEx()` which wasn't introduced until CE 2.11. Systems running |
| 133 | +CE 2.11 and later (HPC Pro, later Palm-sized PCs, HPC 2000 and Pocket PCs) are |
| 134 | +subject to standard SQLite 2.8 concurrency limitations when running a 2.11+ |
| 135 | +targeted build. |
| 136 | + |
| 137 | +### Console |
| 138 | + |
| 139 | +Although later versions of Windows CE ship with a primitive command shell, |
| 140 | +SQLite/CE does not assume its presence or support it, and thus does not implement |
| 141 | +a command-line client. All database management and queries must be executed through |
| 142 | +applications using the library's C API or through SQLite/CEdit. Debug output |
| 143 | +for developers can be handled using `OutputDebugStringW()`. |
| 144 | + |
| 145 | +### Path limits |
| 146 | + |
| 147 | +Like standard Windows, Windows CE has an upper limit of 260 characters for |
| 148 | +file paths. |
| 149 | + |
| 150 | +### Memory constraints |
| 151 | + |
| 152 | +While not a specific SQLite limitation, working with large datasets, even from |
| 153 | +storage cards, can easily exceed the small memories of most Windows CE devices. |
| 154 | +Design queries accordingly. |
| 155 | + |
| 156 | +# Notes and acknowledgements |
| 157 | + |
| 158 | +SQLite/CE is based on SQLite 2.8.17, created by D. Richard Hipp and released to |
| 159 | +the public domain. |
| 160 | + |
| 161 | +## Generative AI |
| 162 | + |
| 163 | +The SQLite/CE port and front-end applications have been developed with a lot of |
| 164 | +AI assistance, primarily from Claude Opus 4.5. While each new feature and change |
| 165 | +is fairly well-tested after implementation and during daily use, be aware that |
| 166 | +this codebase may have some strange patterns or bugs littered throughout it. The |
| 167 | +core SQLite source (located at `src/sqlite` in this repository) remains original |
| 168 | +to the official SQLite 2.8 source distribution, while modifications specific |
| 169 | +to the port can be found at `src/sqlite-ce`. Thus far, the core port has |
| 170 | +proven remarkably reliable for most common use, aside from some early memory |
| 171 | +alignment bugs that hampered testing, but always be aware! |
| 172 | + |
| 173 | +## Tooling and development |
| 174 | + |
| 175 | +The SQLite/CE suite is built and tested under Windows NT 4.0 and Visual C++ 6.0 |
| 176 | +with the relevant Windows CE SDKs. Project files and setup instructions will |
| 177 | +be provided as SQLite/CE begins moving towards targeting Windows CE 2.11 |
| 178 | +and platform-specific configuration for all architectures are solidified. |
| 179 | + |
| 180 | +## Licensing |
| 181 | + |
| 182 | +In the spirit of SQLite's own licensing practice, the library port sources at |
| 183 | +`src/sqlite-ce` are also released to the public domain. The frontend |
| 184 | +applications remain under a BSD 2-clause license. |
| 185 | + |
| 186 | +For full details, please see the project [LICENSE file](https://github.com/nfinit/SQLiteCE/blob/main/LICENSE). |
0 commit comments