My favorites
▼
|
Sign in
pyodbc
Python ODBC library
Project Home
Downloads
Wiki
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
81
attachment: pyodbc_issue.py
(1.9 KB)
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
from unittest import TestCase, main
from pyodbc import connect
class pyodbcTC(TestCase):
def setUp(self):
self.cnx = connect("DRIVER={SQL Native Client};SERVER=localhost;DATABASE=alf;UID=alexandre;PWD=toto")
cursor = self.cnx.cursor()
try:
cursor.execute('create table TestLargeString (id int, data varchar(max))')
except Exception, exc:
print exc
try:
cursor.execute('create table TestBlob (id int, data varbinary(max))')
except Exception, exc:
print exc
cursor.close()
def tearDown(self):
self.cnx.rollback()
cursor = self.cnx.cursor()
cursor.execute('drop table TestBlob')
cursor.execute('drop table TestLargeString')
cursor.close()
self.cnx.close()
def test_blob(self):
cursor = self.cnx.cursor()
data_length = xrange(400*1024-10, 400*1024+10)
for length in data_length:
data = buffer('1'*length)
print "inserting string of length", len(data)
cursor.execute('insert into TestBlob(id, data) VALUES(?, ?)',
length, data)
self.cnx.commit()
cursor.execute('select count(*) from TestBlob')
print '%d rows in table' % (cursor.fetchone()[0])
cursor.close()
def test_large_string(self):
cursor = self.cnx.cursor()
data_length = xrange(400*1024-10, 400*1024+10)
for length in data_length:
data = '1'*length
print "inserting string of length", len(data)
cursor.execute('insert into TestLargeString(id, data) VALUES(?, ?)',
length, data)
self.cnx.commit()
cursor.execute('select count(*) from TestLargeString')
print '%d rows in table' % (cursor.fetchone()[0])
cursor.close()
if __name__ == '__main__':
main()
Powered by
Google Project Hosting