Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(90340)

Side by Side Diff: Lib/sqlite3/dbapi2.py

Issue 10203: sqlite3.Row doesn't support sequence protocol
Patch Set: Created 5 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/sqlite3/test/factory.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # pysqlite2/dbapi2.py: the DB-API 2.0 interface 1 # pysqlite2/dbapi2.py: the DB-API 2.0 interface
2 # 2 #
3 # Copyright (C) 2004-2005 Gerhard Häring <gh@ghaering.de> 3 # Copyright (C) 2004-2005 Gerhard Häring <gh@ghaering.de>
4 # 4 #
5 # This file is part of pysqlite. 5 # This file is part of pysqlite.
6 # 6 #
7 # This software is provided 'as-is', without any express or implied 7 # This software is provided 'as-is', without any express or implied
8 # warranty. In no event will the authors be held liable for any damages 8 # warranty. In no event will the authors be held liable for any damages
9 # arising from the use of this software. 9 # arising from the use of this software.
10 # 10 #
11 # Permission is granted to anyone to use this software for any purpose, 11 # Permission is granted to anyone to use this software for any purpose,
12 # including commercial applications, and to alter it and redistribute it 12 # including commercial applications, and to alter it and redistribute it
13 # freely, subject to the following restrictions: 13 # freely, subject to the following restrictions:
14 # 14 #
15 # 1. The origin of this software must not be misrepresented; you must not 15 # 1. The origin of this software must not be misrepresented; you must not
16 # claim that you wrote the original software. If you use this software 16 # claim that you wrote the original software. If you use this software
17 # in a product, an acknowledgment in the product documentation would be 17 # in a product, an acknowledgment in the product documentation would be
18 # appreciated but is not required. 18 # appreciated but is not required.
19 # 2. Altered source versions must be plainly marked as such, and must not be 19 # 2. Altered source versions must be plainly marked as such, and must not be
20 # misrepresented as being the original software. 20 # misrepresented as being the original software.
21 # 3. This notice may not be removed or altered from any source distribution. 21 # 3. This notice may not be removed or altered from any source distribution.
22 22
23 import datetime 23 import datetime
24 import time 24 import time
25 from collections.abc import Sequence
25 26
26 from _sqlite3 import * 27 from _sqlite3 import *
27 28
28 paramstyle = "qmark" 29 paramstyle = "qmark"
29 30
30 threadsafety = 1 31 threadsafety = 1
31 32
32 apilevel = "2.0" 33 apilevel = "2.0"
33 34
34 Date = datetime.date 35 Date = datetime.date
35 36
36 Time = datetime.time 37 Time = datetime.time
37 38
38 Timestamp = datetime.datetime 39 Timestamp = datetime.datetime
39 40
40 def DateFromTicks(ticks): 41 def DateFromTicks(ticks):
41 return Date(*time.localtime(ticks)[:3]) 42 return Date(*time.localtime(ticks)[:3])
42 43
43 def TimeFromTicks(ticks): 44 def TimeFromTicks(ticks):
44 return Time(*time.localtime(ticks)[3:6]) 45 return Time(*time.localtime(ticks)[3:6])
45 46
46 def TimestampFromTicks(ticks): 47 def TimestampFromTicks(ticks):
47 return Timestamp(*time.localtime(ticks)[:6]) 48 return Timestamp(*time.localtime(ticks)[:6])
48 49
49 version_info = tuple([int(x) for x in version.split(".")]) 50 version_info = tuple([int(x) for x in version.split(".")])
50 sqlite_version_info = tuple([int(x) for x in sqlite_version.split(".")]) 51 sqlite_version_info = tuple([int(x) for x in sqlite_version.split(".")])
51 52
52 Binary = memoryview 53 Binary = memoryview
54 Sequence.register(Row)
53 55
54 def register_adapters_and_converters(): 56 def register_adapters_and_converters():
55 def adapt_date(val): 57 def adapt_date(val):
56 return val.isoformat() 58 return val.isoformat()
57 59
58 def adapt_datetime(val): 60 def adapt_datetime(val):
59 return val.isoformat(" ") 61 return val.isoformat(" ")
60 62
61 def convert_date(val): 63 def convert_date(val):
62 return datetime.date(*map(int, val.split(b"-"))) 64 return datetime.date(*map(int, val.split(b"-")))
(...skipping 15 matching lines...) Expand all
78 register_adapter(datetime.date, adapt_date) 80 register_adapter(datetime.date, adapt_date)
79 register_adapter(datetime.datetime, adapt_datetime) 81 register_adapter(datetime.datetime, adapt_datetime)
80 register_converter("date", convert_date) 82 register_converter("date", convert_date)
81 register_converter("timestamp", convert_timestamp) 83 register_converter("timestamp", convert_timestamp)
82 84
83 register_adapters_and_converters() 85 register_adapters_and_converters()
84 86
85 # Clean up namespace 87 # Clean up namespace
86 88
87 del(register_adapters_and_converters) 89 del(register_adapters_and_converters)
OLDNEW
« no previous file with comments | « no previous file | Lib/sqlite3/test/factory.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+