1+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+ < html >
3+ < head >
4+ < meta content ="text/html; charset=utf-8 " http-equiv ="content-type ">
5+ < title > SQLObject and Python 3</ title >
6+ < link href ="layout.css " type ="text/css " rel ="stylesheet ">
7+ </ head >
8+ < body >
9+ < div id ="page ">
10+ < h1 class ="doc-title "> < a > </ a > </ h1 >
11+ < div id ="navcontainer ">
12+ < ul id ="navlist ">
13+ < li class ="pagenav ">
14+ < ul >
15+ < li class ="page_item ">
16+ < a href ="index.html " title ="Project Home / Index "> SQLObject</ a >
17+ </ li >
18+ < li class ="page_item ">
19+ < a href ="module-index.html " title ="sqlobject package and module reference "> Modules</ a >
20+ </ li >
21+ < li >
22+ < a href ="community.html " title ="Mailing List "> Discuss</ a >
23+ </ li >
24+ < li >
25+ < a href ="SQLObject.html "> Documentation</ a >
26+ </ li >
27+ </ ul >
28+ </ li >
29+ </ ul >
30+ </ div >
31+ < hr >
32+ < div id ="content "> < div class ="rst-doc ">
33+ < h1 class ="pudge-member-page-heading "> SQLObject and Python 3</ h1 >
34+ < div class ="contents topic " id ="contents ">
35+ < p class ="topic-title first "> Contents</ p >
36+ < ul class ="simple ">
37+ < li > < a href ="#changes-between-python-2-and-python-3 " class ="reference internal " id ="id1 "> Changes between Python 2 and Python 3</ a > < ul >
38+ < li > < a href ="#blobcol " class ="reference internal " id ="id2 "> BLOBCol</ a > </ li >
39+ < li > < a href ="#stringcol " class ="reference internal " id ="id3 "> StringCol</ a > </ li >
40+ < li > < a href ="#unicodecol " class ="reference internal " id ="id4 "> UnicodeCol</ a > </ li >
41+ </ ul >
42+ </ li >
43+ < li > < a href ="#python-3-and-mysql " class ="reference internal " id ="id5 "> Python 3 and MySQL</ a > </ li >
44+ < 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 >
45+ < li > < a href ="#sqlite " class ="reference internal " id ="id7 "> SQLite</ a > </ li >
46+ < li > < a href ="#postgres " class ="reference internal " id ="id8 "> Postgres</ a > </ li >
47+ < li > < a href ="#mysql " class ="reference internal " id ="id9 "> MySQL</ a > </ li >
48+ </ ul >
49+ </ li >
50+ </ ul >
51+ </ div >
52+ < div class ="section " id ="changes-between-python-2-and-python-3 ">
53+ < h1 > < a href ="#id1 " class ="toc-backref "> Changes between Python 2 and Python 3</ a > </ h1 >
54+ < p > There are a few changes in the behaviour of SQLObject on Python 3, due to
55+ the changed stings / bytes handling introduced in Python 3.0.</ p >
56+ < div class ="section " id ="blobcol ">
57+ < h2 > < a href ="#id2 " class ="toc-backref "> BLOBCol</ a > </ h2 >
58+ < p > In Python 3, BLOBCol now accepts and returns bytes, rather than strings as it
59+ did in Python 2.</ p >
60+ </ div >
61+ < div class ="section " id ="stringcol ">
62+ < h2 > < a href ="#id3 " class ="toc-backref "> StringCol</ a > </ h2 >
63+ < p > In Python 3, StringCol now accepts arbitrary Unicode strings.</ p >
64+ </ div >
65+ < div class ="section " id ="unicodecol ">
66+ < h2 > < a href ="#id4 " class ="toc-backref "> UnicodeCol</ a > </ h2 >
67+ < p > The dbEncoding parameter to UnicodeCol has no effect in Python 3 code. This
68+ is now handled by the underlying database layer and is no longer exposed
69+ via SQLObject. The parameter is still available for those writing Python 2
70+ compatible code.</ p >
71+ </ div >
72+ </ div >
73+ < div class ="section " id ="python-3-and-mysql ">
74+ < h1 > < a href ="#id5 " class ="toc-backref "> Python 3 and MySQL</ a > </ h1 >
75+ < 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.
76+ Note that the default encoding of MySQL databases is < em > latin1</ em > , which can cause
77+ problems with general Unicode strings. We recommend specifying the character
78+ set as < em > utf8</ em > when using MySQL to protect against these issues.</ p >
79+ </ div >
80+ < div class ="section " id ="using-databases-created-with-sqlobject-and-python-2-in-python-3 ">
81+ < h1 > < a href ="#id6 " class ="toc-backref "> Using databases created with SQLObject and Python 2 in Python 3</ a > </ h1 >
82+ < p > For most cases, things should just work as before. The only issues should
83+ around UnicodeCol, as how this is handled has changed.</ p >
84+ < div class ="section " id ="sqlite ">
85+ < h2 > < a href ="#id7 " class ="toc-backref "> SQLite</ a > </ h2 >
86+ < p > The Python 3 sqlite driver expects Unicode columns to be encoded using
87+ utf8. Columns created using the default encoding on Python 2 should work fine,
88+ but columns created with a different encoding set using the dbEncoding
89+ parameter may cause problems.</ p >
90+ </ div >
91+ < div class ="section " id ="postgres ">
92+ < h2 > < a href ="#id8 " class ="toc-backref "> Postgres</ a > </ h2 >
93+ < p > Postgres' behaviour is similar to sqlite. Columns created using the
94+ default encoding on Python 2 should work fine, but columns created with a
95+ different encoding set using the dbEncoding may cause problems.</ p >
96+ </ div >
97+ < div class ="section " id ="mysql ">
98+ < h2 > < a href ="#id9 " class ="toc-backref "> MySQL</ a > </ h2 >
99+ < p > For MySQL, the results depend on whether the Python 2 database was using
100+ MySQLdb's Unicode mode or not.</ p >
101+ < p > If a character set was specified for the database using the charset parameter,
102+ such as:</ p >
103+ < pre class ="literal-block ">
104+ mysql:///localhost/test?charset=latin1
105+ </ pre >
106+ < p > Things should work provided the same character set is specified when using
107+ Python 3.</ p >
108+ < p > If a character set wasn't specified, then things may work if the character set
109+ is set to match the dbEncoding parameter used when defining the UnicodeCol.</ p >
110+ </ div >
111+ </ div >
112+ </ div > </ div >
113+ < div id ="footer ">
114+ < p style ="float: left; ">
115+ built with
116+ < a href ="http://lesscode.org/projects/pudge/ "> pudge/0.1.3</ a > |
117+ original design by
118+ < a href ="http://blog.ratterobert.com/ "> ratter / robert</ a >
119+ </ p >
120+ < div >
121+ < br > <!--
122+ <a name="search">
123+ <form method="get" id="searchform"
124+ action="http://lesscode.org/blog/index.php">
125+ <div>
126+ <input type="text" value="" name="s" id="s" />
127+ <input type="submit" id="searchsubmit" value="Search" />
128+ </div>
129+ </form>
130+ </a> -->
131+ < br >
132+ </ div >
133+ </ div >
134+ </ div >
135+ </ body >
136+ </ html >
0 commit comments