/usr/share/doc/python-apsw/html/types.html is in python-apsw-doc 3.7.6.3-r1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Types — APSW 3.7.6.3-r1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '3.7.6.3-r1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="copyright" title="Copyright" href="copyright.html" />
<link rel="top" title="APSW 3.7.6.3-r1 documentation" href="index.html" />
<link rel="next" title="Execution and tracing" href="execution.html" />
<link rel="prev" title="Exceptions" href="exceptions.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="execution.html" title="Execution and tracing"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="exceptions.html" title="Exceptions"
accesskey="P">previous</a> |</li>
<li><a href="index.html">APSW 3.7.6.3-r1 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="types">
<span id="id1"></span><h1>Types<a class="headerlink" href="#types" title="Permalink to this headline">¶</a></h1>
<p>Read about <a class="reference external" href="http://www.sqlite.org/datatype3.html">SQLite 3 types</a>. ASPW always maintains the
correct type for values, and never converts them to something
else. Note however that SQLite may convert types based on column
affinity as <a class="reference external" href="http://www.sqlite.org/datatype3.html">described</a>. ASPW
requires that all values supplied are one of the corresponding
Python/SQLite types (or a subclass).</p>
<div class="section" id="mapping">
<h2>Mapping<a class="headerlink" href="#mapping" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>None in Python is NULL in SQLite</li>
<li>Python int or long is INTEGER in SQLite. The value represented must
fit within a 64 bit signed quantity (long long at the C level) or an
overflow exception is generated.</li>
<li>Python’s float type is used for REAL in SQLite. (At the C level they
are both 8 byte quantities and there is no loss of precision).</li>
<li>In Python 2, Python’s string or unicode is used for TEXT supplied to
SQLite and all text returned from SQLite is unicode. For Python 3
only unicode is used.</li>
<li>For Python 2 the buffer class is used for BLOB in SQLite. In Python
3 the bytes type is used, although you can still supply buffers.</li>
</ul>
</div>
<div class="section" id="unicode">
<span id="id2"></span><h2>Unicode<a class="headerlink" href="#unicode" title="Permalink to this headline">¶</a></h2>
<p>All SQLite strings are Unicode. The actual binary representations can
be UTF8, or UTF16 in either byte order. ASPW uses the UTF8 interface
to SQLite which results in the binary string representation in your
database defaulting to UTF8 as well. All this is totally transparent
to your Python code.</p>
<p>Everywhere strings are used (eg as database values, SQL statements,
bindings names, user defined functions) you can use Unicode strings,
and in Python 3 must use Unicode. In Python 2, you can also use the
bare Python string class, and ASPW will automatically call the unicode
converter if any non-ascii characters are present.</p>
<p>When returning text values from SQLite, ASPW always uses the Python
unicode class.</p>
<p>If you don’t know much about Unicode then read <a class="reference external" href="http://www.joelonsoftware.com/articles/Unicode.html">Joel’s article</a>. SQLite does
not include conversion from random non-Unicode encodings to or from
Unicode. (It does include conversion between 8 bit and 16 bit Unicode
encodings). Python includes <a class="reference external" href="http://www.python.org/doc/2.5.2/lib/module-codecs.html">codecs</a> for
conversion to or from many different character sets.</p>
<p>If you don’t want to use Unicode and instead want a simple bytes in
are the same bytes out then you should only use blobs.</p>
<p>If you want to do manipulation of unicode text such as upper/lower
casing or sorting then you need to know about locales. This is
because the exact same sequence of characters sort, upper case, lower
case etc differently depending on where you are. As an example Turkic
languages have multiple letter i, German has ß which behaves like ss,
various accents sort differently in different European countries.
Fortunately there is a libary you can ask to do the right locale
specific thing <a class="reference external" href="http://en.wikipedia.org/wiki/International_Components_for_Unicode">ICU</a>.
A default SQLite compilation only deals with the 26 letter Roman
alphabet. If you enable ICU with SQLite then you get <a class="reference external" href="http://www.sqlite.org/src/finfo?name=ext/icu/README.txt">good stuff</a>.
See the <a class="reference internal" href="build.html#building"><em>Building</em></a> section on how to enable ICU for SQLite with
APSW. Note that Python does not currently include ICU support and
hence sorting, upper/lower casing etc are limited and do not take
locales into account.</p>
<p>In summary, never confuse bytes with strings (which C sadly treats as
the same thing). Either always use bytes (and SQLite blobs) for
everything or use strings (and SQLite strings) for everything. If you
take the latter approach and have to deal with external input/output
then you must know what encodings are being used and it is best to
convert to Unicode as early as possible on input and late as possible on
output.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Types</a><ul>
<li><a class="reference internal" href="#mapping">Mapping</a></li>
<li><a class="reference internal" href="#unicode">Unicode</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="exceptions.html"
title="previous chapter">Exceptions</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="execution.html"
title="next chapter">Execution and tracing</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/types.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="execution.html" title="Execution and tracing"
>next</a> |</li>
<li class="right" >
<a href="exceptions.html" title="Exceptions"
>previous</a> |</li>
<li><a href="index.html">APSW 3.7.6.3-r1 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© <a href="copyright.html">Copyright</a> 2004-2010, Roger Binns <rogerb@rogerbinns.com>.
Last updated on May 20, 2011.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1pre/4b8d012cf82e.
</div>
</body>
</html>
|