File: Python3.html

package info (click to toggle)
sqlobject 3.1.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,280 kB
  • ctags: 17,912
  • sloc: python: 16,713; sh: 18; makefile: 13
file content (137 lines) | stat: -rw-r--r-- 6,387 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type">
<title>SQLObject and Python 3</title>
    <link href="layout.css" type="text/css" rel="stylesheet">
  </head>
  <body>
    <div id="page">
      <h1 class="doc-title"><a></a></h1>
      <div id="navcontainer">
		    <ul id="navlist">
          <li class="pagenav">
            <ul>
              <li class="page_item">
                <a href="index.html" title="Project Home / Index">SQLObject</a>
              </li>
              <li class="page_item">
                <a href="module-index.html" title="sqlobject package and module reference">Modules</a>
              </li>
              <li>
                <a href="community.html" title="Mailing List">Discuss</a>
              </li>
	      <li>
	        <a href="SQLObject.html">Documentation</a>
	      </li>
            </ul>
          </li>
        </ul>
      </div>
      <hr>
      <div id="content"><div class="rst-doc">
  <h1 class="pudge-member-page-heading">SQLObject and Python 3</h1>
  <div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a href="#changes-between-python-2-and-python-3" class="reference internal" id="id1">Changes between Python 2 and Python 3</a><ul>
<li><a href="#blobcol" class="reference internal" id="id2">BLOBCol</a></li>
<li><a href="#stringcol" class="reference internal" id="id3">StringCol</a></li>
<li><a href="#unicodecol" class="reference internal" id="id4">UnicodeCol</a></li>
</ul>
</li>
<li><a href="#python-3-and-mysql" class="reference internal" id="id5">Python 3 and MySQL</a></li>
<li><a href="#using-databases-created-with-sqlobject-and-python-2-in-python-3" class="reference internal" id="id6">Using databases created with SQLObject and Python 2 in Python 3</a><ul>
<li><a href="#sqlite" class="reference internal" id="id7">SQLite</a></li>
<li><a href="#postgres" class="reference internal" id="id8">Postgres</a></li>
<li><a href="#mysql" class="reference internal" id="id9">MySQL</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="changes-between-python-2-and-python-3">
<h1><a href="#id1" class="toc-backref">Changes between Python 2 and Python 3</a></h1>
<p>There are a few changes in the behaviour of SQLObject on Python 3, due to
the changed stings / bytes handling introduced in Python 3.0.</p>
<div class="section" id="blobcol">
<h2><a href="#id2" class="toc-backref">BLOBCol</a></h2>
<p>In Python 3, BLOBCol now accepts and returns bytes, rather than strings as it
did in Python 2.</p>
</div>
<div class="section" id="stringcol">
<h2><a href="#id3" class="toc-backref">StringCol</a></h2>
<p>In Python 3, StringCol now accepts arbitrary Unicode strings.</p>
</div>
<div class="section" id="unicodecol">
<h2><a href="#id4" class="toc-backref">UnicodeCol</a></h2>
<p>The dbEncoding parameter to UnicodeCol has no effect in Python 3 code. This
is now handled by the underlying database layer and is no longer exposed
via SQLObject. The parameter is still available for those writing Python 2
compatible code.</p>
</div>
</div>
<div class="section" id="python-3-and-mysql">
<h1><a href="#id5" class="toc-backref">Python 3 and MySQL</a></h1>
<p>SQLObject is tested using <a href="https://pypi.python.org/pypi/mysqlclient" class="reference external">mysqlclient</a> as the database driver on Python 3.
Note that the default encoding of MySQL databases is <em>latin1</em>, which can cause
problems with general Unicode strings. We recommend specifying the character
set as <em>utf8</em> when using MySQL to protect against these issues.</p>
</div>
<div class="section" id="using-databases-created-with-sqlobject-and-python-2-in-python-3">
<h1><a href="#id6" class="toc-backref">Using databases created with SQLObject and Python 2 in Python 3</a></h1>
<p>For most cases, things should just work as before. The only issues should
around UnicodeCol, as how this is handled has changed.</p>
<div class="section" id="sqlite">
<h2><a href="#id7" class="toc-backref">SQLite</a></h2>
<p>The Python 3 sqlite driver expects Unicode columns to be encoded using
utf8. Columns created using the default encoding on Python 2 should work fine,
but columns created with a different encoding set using the dbEncoding
parameter may cause problems.</p>
</div>
<div class="section" id="postgres">
<h2><a href="#id8" class="toc-backref">Postgres</a></h2>
<p>Postgres' behaviour is similar to sqlite. Columns created using the
default encoding on Python 2 should work fine, but columns created with a
different encoding set using the dbEncoding may cause problems.</p>
</div>
<div class="section" id="mysql">
<h2><a href="#id9" class="toc-backref">MySQL</a></h2>
<p>For MySQL, the results depend on whether the Python 2 database was using
MySQLdb's Unicode mode or not.</p>
<p>If a character set was specified for the database using the charset parameter,
such as:</p>
<pre class="literal-block">
mysql:///localhost/test?charset=latin1
</pre>
<p>Things should work provided the same character set is specified when using
Python 3.</p>
<p>If a character set wasn't specified, then things may work if the character set
is set to match the dbEncoding parameter used when defining the UnicodeCol.</p>
<a href="https://sourceforge.net/projects/sqlobject" class="reference external image-reference"><img src="https://sourceforge.net/sflogo.php?group_id=74338&amp;type=10" alt="Get SQLObject at SourceForge.net. Fast, secure and Free Open Source software downloads" style="width: 80px; height: 15px;" class="noborder align-center"></a>
</div>
</div>
</div></div>
      <div id="footer">
        <p style="float: left;">
          built with 
          <a href="http://lesscode.org/projects/pudge/">pudge/0.1.3</a> |
		      original design by 
          <a href="http://blog.ratterobert.com/">ratter / robert</a>
	      </p>
        <div>
        <br> <!--
        <a name="search">
          <form method="get" id="searchform" 
                action="http://lesscode.org/blog/index.php">
            <div>
              <input type="text" value="" name="s" id="s" />
              <input type="submit" id="searchsubmit" value="Search" />
            </div>
          </form>
        </a> -->
        <br>
        </div>
      </div>
    </div>
  </body>
</html>