mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Issue #27188: Fix various sqlite3 documentation errors
* Connection.execute* methods don't create intermediate cursor objects * Fix description of seq_of_parameters parameter * Clarify that Warning is sqlite3.Warning * sql_script parameter of Cursor.executescript() doesn't accept bytes * Add missing tests * Fix various markup errors Initial patch by Dave Sawyer.
This commit is contained in:
parent
00eaa8a53b
commit
c415440faa
2 changed files with 31 additions and 18 deletions
|
@ -250,6 +250,11 @@ class CursorTests(unittest.TestCase):
|
|||
row = self.cu.fetchone()
|
||||
self.assertEqual(row[0], "Hu\x00go")
|
||||
|
||||
def CheckExecuteNonIterable(self):
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
self.cu.execute("insert into test(id) values (?)", 42)
|
||||
self.assertEqual(str(cm.exception), 'parameters are of unsupported type')
|
||||
|
||||
def CheckExecuteWrongNoOfArgs1(self):
|
||||
# too many parameters
|
||||
try:
|
||||
|
@ -725,6 +730,13 @@ class ExtensionTests(unittest.TestCase):
|
|||
raised = True
|
||||
self.assertEqual(raised, True, "should have raised an exception")
|
||||
|
||||
def CheckCursorExecutescriptAsBytes(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
cur = con.cursor()
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
cur.executescript(b"create table test(foo); insert into test(foo) values (5);")
|
||||
self.assertEqual(str(cm.exception), 'script argument must be unicode.')
|
||||
|
||||
def CheckConnectionExecute(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
result = con.execute("select 5").fetchone()[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue