ceodbc-users Mailing List for ceODBC
Brought to you by:
atuining
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(10) |
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2010 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
(8) |
Aug
|
Sep
(3) |
Oct
(2) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(7) |
Jul
|
Aug
|
Sep
(3) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2015 |
Jan
|
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Andrew Z. <AZ...@us...> - 2015-08-31 14:40:56
|
Anthony, setoutputsize () works perfectly, and now I see I missed it in the documentation. :) Andrew From: Anthony Tuininga [mailto:ant...@gm...] Sent: Friday, August 28, 2015 5:10 PM To: Andrew Ziem (GMC-USA-BUSINESS INTELLIGENCE SR. ANALYST) Cc: ceo...@li... Subject: Re: error querying large images Hi Andrew, The default size for "text" and "image" columns is 128k (131072). If you want something larger than that you need to use setoutputsizes() to say as much. The other possibility is a feature I haven't integrated yet -- specifically a method that is called when variables/buffers are being created that lets you decide at that point what size/type to create. Anthony On Fri, Aug 28, 2015 at 4:14 PM, Andrew Ziem <AZ...@us...> wrote: When querying a column of type image from Microsoft SQL Server 10.50.6220 I get the error ceODBC.DatabaseError: column 2 (0) truncated (need 208875, have 131072) But when I switch to pyODBC just by changing the connect() function, pyODBC works. Also, if I modify the query with "where DATALENGTH(image_file) < 130000" then ceODBC works too. I am not able to make any changes to the remote database (e.g., shrink image or change column type). System environment * Microsoft Windows 7 64-bit * Microsoft SQL Server 10.50.6220 * Python 2.7.9 32-bit * ceODBC 2.0.1 * pyodbc 3.0.10 Andrew |
|
From: Anthony T. <ant...@gm...> - 2015-08-28 23:11:06
|
Hi Andrew, Yes, I know. It is long overdue. I hope to make a new release soon! Anthony On Fri, Aug 28, 2015 at 4:19 PM, Andrew Ziem <AZ...@us...> wrote: > For my next project I am considering using Python 3.4 and am hoping for > ceODBC Windows installer for Python 3.4, but > http://ceodbc.sourceforge.net/ lists only Python 3.2 > > > > > > > > Andrew > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > ceodbc-users mailing list > ceo...@li... > https://lists.sourceforge.net/lists/listinfo/ceodbc-users > > |
|
From: Anthony T. <ant...@gm...> - 2015-08-28 23:10:13
|
Hi Andrew, The default size for "text" and "image" columns is 128k (131072). If you want something larger than that you need to use setoutputsizes() to say as much. The other possibility is a feature I haven't integrated yet -- specifically a method that is called when variables/buffers are being created that lets you decide at that point what size/type to create. Anthony On Fri, Aug 28, 2015 at 4:14 PM, Andrew Ziem <AZ...@us...> wrote: > When querying a column of type image from Microsoft SQL Server 10.50.6220 > I get the error > ceODBC.DatabaseError: column 2 (0) truncated (need 208875, have > 131072) > > But when I switch to pyODBC just by changing the connect() function, > pyODBC works. Also, if I modify the query with "where > DATALENGTH(image_file) < 130000" then ceODBC works too. > > I am not able to make any changes to the remote database (e.g., shrink > image or change column type). > > System environment > * Microsoft Windows 7 64-bit > * Microsoft SQL Server 10.50.6220 > * Python 2.7.9 32-bit > * ceODBC 2.0.1 > * pyodbc 3.0.10 > > > > > Andrew > > |
|
From: Andrew Z. <AZ...@us...> - 2015-08-28 22:37:24
|
For my next project I am considering using Python 3.4 and am hoping for ceODBC Windows installer for Python 3.4, but http://ceodbc.sourceforge.net/ lists only Python 3.2 Andrew |
|
From: Andrew Z. <AZ...@us...> - 2015-08-28 22:32:15
|
When querying a column of type image from Microsoft SQL Server 10.50.6220 I get the error ceODBC.DatabaseError: column 2 (0) truncated (need 208875, have 131072) But when I switch to pyODBC just by changing the connect() function, pyODBC works. Also, if I modify the query with "where DATALENGTH(image_file) < 130000" then ceODBC works too. I am not able to make any changes to the remote database (e.g., shrink image or change column type). System environment * Microsoft Windows 7 64-bit * Microsoft SQL Server 10.50.6220 * Python 2.7.9 32-bit * ceODBC 2.0.1 * pyodbc 3.0.10 Andrew |
|
From: fernando b. <fba...@gm...> - 2015-04-13 04:09:56
|
I'm trying to move an existing application from windows to linux,
everything seems to work well except for our lone exececutemany() command.
Everytime it runs with more than 1 param it segfaults.
I have tried this on a RHEL6 machine and a centOS7 VM both 64bit.
Currently our setup looks like ceodbc ->freetds -> unixodbc.
If we change it to a simple for loop it works fine, if we switch out ceodbc
to pyodbc it works but everything runs slower. We would really like to
just use the code as is.
In an effort to try a different version I noticed that when I pip installed
I got the following on versions 2.0 and 2.01:
Installing collected packages: ceodbc
Running setup.py install for ceodbc
building 'ceODBC' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
-D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
-D_GNU_SOURCE -fPIC -fwrapv -fPIC -DBUILD_VERSION=2.0
-DBUILD_LEGACY_64_BIT_MODE -I/usr/include/python2.7 -c ceODBC.c -o
build/temp.linux-x86_64-2.7/ceODBC.o
In file included from Cursor.c:159:0,
from Connection.c:161,
from ceODBC.c:171:
Variable.c: In function ‘Variable_GetValue’:
Variable.c:759:17: warning: format ‘%lu’ expects argument of type ‘long
unsigned int’, but argument 5 has type ‘SQLINTEGER’ [-Wformat=]
self->bufferSize);
^
Variable.c:759:17: warning: format ‘%lu’ expects argument of type ‘long
unsigned int’, but argument 6 has type ‘SQLUINTEGER’ [-Wformat=]
In file included from Connection.c:161:0,
from ceODBC.c:171:
Cursor.c: In function ‘Cursor_PrepareResultSet’:
Cursor.c:376:13: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
(SQLPOINTER) self->fetchArraySize, SQL_IS_INTEGER);
^
Cursor.c: In function ‘Cursor_ExecuteMany’:
Cursor.c:1184:13: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
(SQLPOINTER) numRows, SQL_IS_UINTEGER);
^
In file included from ceODBC.c:171:0:
Connection.c: In function ‘Connection_SetAutoCommit’:
Connection.c:852:13: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
(SQLPOINTER) sqlValue, SQL_IS_UINTEGER);
^
gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/ceODBC.o
-L/usr/lib64 -lodbc -lpython2.7 -o build/lib.linux-x86_64-2.7/ceODBC.so
Would this be the cause of the problem? On RHEL6 gcc = 4.4.7 and on centOS
its 4.8.3.
Has anyone run into this problem? I've been having a hard time coming
across answered/resolved queries on similar questions on the web.
If I run it through gbt below is the bt (run on dummy code that inserts
several dates using executemany):
Program received signal SIGSEGV, Segmentation fault.
tds_quote_and_put (tds=tds@entry=0x7b53b0, s=0x7d3000 <Address 0x7d3000 out
of bounds>, s@entry=0x6cb694 "2015-04-12 23:03:29", end=end@entry=0xe6d334
<Address 0xe6d334 out of bounds>) at query.c:3088
3088 buf[i++] = *s;
#0 tds_quote_and_put (tds=tds@entry=0x7b53b0, s=0x7d3000 <Address 0x7d3000
out of bounds>, s@entry=0x6cb694 "2015-04-12 19:58:54", end=end@entry=0xe6d334
<Address 0xe6d334 out of bounds>) at query.c:3088
#1 0x00007fffeea79c07 in tds_put_param_as_string (tds=tds@entry=0x7b53b0,
n=n@entry=0, params=0x74b1e0) at query.c:3175
#2 0x00007fffeea7a9f0 in tds_send_emulated_execute (tds=0x7b53b0,
query=<optimized out>, params=0x74b1e0) at query.c:3236
#3 0x00007fffeea5447d in _SQLExecute (stmt=stmt@entry=0x7b5d30) at
odbc.c:3352
#4 0x00007fffeea593e8 in SQLExecute (hstmt=0x7b5d30) at odbc.c:3539
#5 0x00007ffff03a3429 in SQLExecute (statement_handle=0x7c5f20) at
SQLExecute.c:287
#6 0x00007ffff05fe468 in Cursor_InternalExecute
(self=self@entry=0x7fffef2c8260)
at Cursor.c:675
#7 0x00007ffff05ff82c in Cursor_ExecuteMany (self=0x7fffef2c8260,
args=<optimized out>) at Cursor.c:1189
#8 0x00007ffff7af5b94 in call_function (oparg=<optimized out>,
pp_stack=0x7fffffffdb10) at /usr/src/debug/Python-2.7.5/Python/ceval.c:4098
#9 PyEval_EvalFrameEx (f=f@entry=Frame 0x6d8bf0, for file p.py, line 12,
in <module> (), throwflag=throwflag@entry=0) at
/usr/src/debug/Python-2.7.5/Python/ceval.c:2740
#10 0x00007ffff7af71ad in PyEval_EvalCodeEx (co=co@entry=0x7ffff7f12f30,
globals=globals@entry={'files': ['ceODBC-2.0.1.tar.gz', 'p.py'],
'dates': [['2015-04-12 19:58:54'], ['2015-04-12 19:58:54']], 'f': 'p.py',
'__builtins__': <module at remote 0x7ffff7f8fb08>, '__file__': 'p.py',
'sql': 'Insert into dbo.dates (date)\n Values(?)', 'db': <module at
remote 0x7fffefd4c520>, 'cnx': <ceODBC.Connection at remote
0x7fffef2caaf0>, '__package__': None, 'cursor': <ceODBC.Cursor at remote
0x7fffef2c8260>, 'time': <module at remote 0x7fffefd4c1a0>, '__name__':
'__main__', 'os': <module at remote 0x7ffff7f56d00>, '__doc__': None, '_':
1, 'con': 'Driver={SQL
Server};Server=server;database=FileStore;UID=sql_dal;PWD=tes;PORT=1433'},
locals=locals@entry={'files': ['ceODBC-2.0.1.tar.gz', 'p.py'], 'dates':
[['2015-04-12 19:58:54'], ['2015-04-12 19:58:54']], 'f': 'p.py',
'__builtins__': <module at remote 0x7ffff7f8fb08>, '__file__': 'p.py',
'sql': 'Insert into dbo.dates (date)\n Values(?)', 'db': <module at
remote 0x7fffefd4c520>, 'cnx': <ceODBC.Connection at remote
0x7fffef2caaf0>, '__package__': None, 'cursor': <ceODBC.Cursor at remote
0x7fffef2c8260>, 'time': <module at remote 0x7fffefd4c1a0>, '__name__':
'__main__', 'os': <module at remote 0x7ffff7f56d00>, '__doc__': None, '_':
1, 'con': 'Driver={SQL
Server};Server=server;database=FileStore;UID=sql_dal;PWD=test;PORT=1433'},
args=args@entry=0x0, argcount=argcount@entry=0, kws=kws@entry=0x0,
kwcount=kwcount@entry=0, defs=defs@entry=0x0, defcount=defcount@entry=0,
closure=closure@entry=0x0)
at /usr/src/debug/Python-2.7.5/Python/ceval.c:3330
#11 0x00007ffff7af72b2 in PyEval_EvalCode (co=co@entry=0x7ffff7f12f30,
globals=globals@entry={'files': ['ceODBC-2.0.1.tar.gz', 'p.py'],
'dates': [['2015-04-12 19:58:54'], ['2015-04-12 19:58:54']], 'f': 'p.py',
'__builtins__': <module at remote 0x7ffff7f8fb08>, '__file__': 'p.py',
'sql': 'Insert into dbo.dates (date)\n Values(?)', 'db': <module at
remote 0x7fffefd4c520>, 'cnx': <ceODBC.Connection at remote
0x7fffef2caaf0>, '__package__': None, 'cursor': <ceODBC.Cursor at remote
0x7fffef2c8260>, 'time': <module at remote 0x7fffefd4c1a0>, '__name__':
'__main__', 'os': <module at remote 0x7ffff7f56d00>, '__doc__': None, '_':
1, 'con': 'Driver={SQL
Server};Server=server;database=FileStore;UID=sql_dal;PWD=test;PORT=1433'},
locals=locals@entry={'files': ['ceODBC-2.0.1.tar.gz', 'p.py'], 'dates':
[['2015-04-12 19:58:54'], ['2015-04-12 19:58:54']], 'f': 'p.py',
'__builtins__': <module at remote 0x7ffff7f8fb08>, '__file__': 'p.py',
'sql': 'Insert into dbo.dates (date)\n Values(?)', 'db': <module at
remote 0x7fffefd4c520>, 'cnx': <ceODBC.Connection at remote
0x7fffef2caaf0>, '__package__': None, 'cursor': <ceODBC.Cursor at remote
0x7fffef2c8260>, 'time': <module at remote 0x7fffefd4c1a0>, '__name__':
'__main__', 'os': <module at remote 0x7ffff7f56d00>, '__doc__': None, '_':
1, 'con': 'Driver={SQL
Server};Server=server;database=FileStore;UID=sql_dal;PWD=test;PORT=1433'})
at /usr/src/debug/Python-2.7.5/Python/ceval.c:689
#12 0x00007ffff7b106ef in run_mod (mod=<optimized out>,
filename=filename@entry=0x7fffffffe284 "p.py",
globals=globals@entry={'files': ['ceODBC-2.0.1.tar.gz', 'p.py'],
'dates': [['2015-04-12 19:58:54'], ['2015-04-12 19:58:54']], 'f': 'p.py',
'__builtins__': <module at remote 0x7ffff7f8fb08>, '__file__': 'p.py',
'sql': 'Insert into dbo.dates (date)\n Values(?)', 'db': <module at
remote 0x7fffefd4c520>, 'cnx': <ceODBC.Connection at remote
0x7fffef2caaf0>, '__package__': None, 'cursor': <ceODBC.Cursor at remote
0x7fffef2c8260>, 'time': <module at remote 0x7fffefd4c1a0>, '__name__':
'__main__', 'os': <module at remote 0x7ffff7f56d00>, '__doc__': None, '_':
1, 'con': 'Driver={SQL
Server};Server=server;database=FileStore;UID=sql_dal;PWD=test;PORT=1433'},
locals=locals@entry={'files': ['ceODBC-2.0.1.tar.gz', 'p.py'], 'dates':
[['2015-04-12 19:58:54'], ['2015-04-12 19:58:54']], 'f': 'p.py',
'__builtins__': <module at remote 0x7ffff7f8fb08>, '__file__': 'p.py',
'sql': 'Insert into dbo.dates (date)\n Values(?)', 'db': <module at
remote 0x7fffefd4c520>, 'cnx': <ceODBC.Connection at remote
0x7fffef2caaf0>, '__package__': None, 'cursor': <ceODBC.Cursor at remote
0x7fffef2c8260>, 'time': <module at remote 0x7fffefd4c1a0>, '__name__':
'__main__', 'os': <module at remote 0x7ffff7f56d00>, '__doc__': None, '_':
1, 'con': 'Driver={SQL
Server};Server=server;database=FileStore;UID=sql_dal;PWD=test;PORT=1433'},
flags=flags@entry=0x7fffffffdd70, arena=arena@entry=0x6b8600) at
/usr/src/debug/Python-2.7.5/Python/pythonrun.c:1373
#13 0x00007ffff7b118ae in PyRun_FileExFlags (fp=fp@entry=0x6df840,
filename=filename@entry=0x7fffffffe284 "p.py", start=start@entry=257,
globals=globals@entry={'files': ['ceODBC-2.0.1.tar.gz', 'p.py'],
'dates': [['2015-04-12 19:58:54'], ['2015-04-12 19:58:54']], 'f': 'p.py',
'__builtins__': <module at remote 0x7ffff7f8fb08>, '__file__': 'p.py',
'sql': 'Insert into dbo.dates (date)\n Values(?)', 'db': <module at
remote 0x7fffefd4c520>, 'cnx': <ceODBC.Connection at remote
0x7fffef2caaf0>, '__package__': None, 'cursor': <ceODBC.Cursor at remote
0x7fffef2c8260>, 'time': <module at remote 0x7fffefd4c1a0>, '__name__':
'__main__', 'os': <module at remote 0x7ffff7f56d00>, '__doc__': None, '_':
1, 'con': 'Driver={SQL
Server};Server=server;database=FileStore;UID=sql_dal;PWD=test;PORT=1433'},
locals=locals@entry={'files': ['ceODBC-2.0.1.tar.gz', 'p.py'], 'dates':
[['2015-04-12 19:58:54'], ['2015-04-12 19:58:54']], 'f': 'p.py',
'__builtins__': <module at remote 0x7ffff7f8fb08>, '__file__': 'p.py',
'sql': 'Insert into dbo.dates (date)\n Values(?)', 'db': <module at
remote 0x7fffefd4c520>, 'cnx': <ceODBC.Connection at remote
0x7fffef2caaf0>, '__package__': None, 'cursor': <ceODBC.Cursor at remote
0x7fffef2c8260>, 'time': <module at remote 0x7fffefd4c1a0>, '__name__':
'__main__', 'os': <module at remote 0x7ffff7f56d00>, '__doc__': None, '_':
1, 'con': 'Driver={SQL Server};Server=server;database=FileSt---Type
<return> to continue, or q <return> to quit---
ore;UID=sql_dal;PWD=test;PORT=1433'}, closeit=closeit@entry=1,
flags=flags@entry=0x7fffffffdd70) at
/usr/src/debug/Python-2.7.5/Python/pythonrun.c:1359
#14 0x00007ffff7b12b39 in PyRun_SimpleFileExFlags (fp=fp@entry=0x6df840,
filename=filename@entry=0x7fffffffe284 "p.py", closeit=closeit@entry=1,
flags=flags@entry=0x7fffffffdd70)
at /usr/src/debug/Python-2.7.5/Python/pythonrun.c:951
#15 0x00007ffff7b13053 in PyRun_AnyFileExFlags (fp=fp@entry=0x6df840,
filename=filename@entry=0x7fffffffe284 "p.py", closeit=closeit@entry=1,
flags=flags@entry=0x7fffffffdd70)
at /usr/src/debug/Python-2.7.5/Python/pythonrun.c:755
#16 0x00007ffff7b23b3f in Py_Main (argc=<optimized out>, argv=<optimized
out>) at /usr/src/debug/Python-2.7.5/Modules/main.c:640
#17 0x00007ffff6d50af5 in __libc_start_main (main=0x4006f0 <main>, argc=2,
ubp_av=0x7fffffffdf38, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffdf28)
at libc-start.c:274
#18 0x0000000000400721 in _start ()
I'm assuming its ceodbc since it only happens with its executemany command.
Any help or suggestions would be greatly appreciated,
-Fernando
|
|
From: Andrew Z. <AZ...@us...> - 2015-02-13 20:25:15
|
I found a workaround: create a new cursor (shown in the attachment). Anthony, do you think this is a bug in ceODBC, the SQL Server driver, or something else? Andrew ------------------------------ From: Andrew Ziem Sent: Thursday, February 12, 2015 11:01 AM To: ceo...@li...; ant...@gm... Subject: [ceodbc-users] freeze with merge statement When I execute a MERGE statement, ceODBC apparently just freezes, but the same MERGE statement in SQL Server Management Studio quickly finishes. My example code is attached. I am using ceODBC 2.0.1, Python 2.7.9, and Windows 7 connected to Microsoft SQL Server 2012 (11.0 SP1). Andrew |
|
From: Andrew Z. <AZ...@us...> - 2015-02-12 18:21:27
|
When I execute a MERGE statement, ceODBC apparently just freezes, but the same MERGE statement in SQL Server Management Studio quickly finishes. My example code is attached. I am using ceODBC 2.0.1, Python 2.7.9, and Windows 7 connected to Microsoft SQL Server 2012 (11.0 SP1). Andrew |
|
From: Andrew Z. <AZ...@us...> - 2014-09-18 18:18:40
|
I am trying to switch from pyodbc to ceODBC because of the much, much faster performance. I can write Unicode with execute(), but executemany() gives the error "TypeError: expecting string data." I tested this behavior with Python 2.7 32-bit, ceODBC 2.0.1, SQL Server 11.0 SP1 and Netezza Release 7.0 (P-1) [Build 26407]. My test code: https://gist.github.com/az0/1a89a166cec5d4d0a3c9 Best regards, Andrew |
|
From: Frank M. <fr...@ch...> - 2012-05-12 09:09:01
|
Hi all
I posted this a while ago and got no response. I have some more information,
if anyone is interested.
> I am using MS Sql Server 2005, python 3.2.2, and ceODBC 2.0.1.
>
> My problem is with Sql Server, not with ceODBC, but I thought
> I would ask here in case someone has figured out a workaround.
>
> Python's datetime.datetime object uses a precision of
> microseconds. Sql Server's DATETIME type only uses a precision of
> milliseconds (to the nearest 3.33ms).
>
> When I try to insert a datetime.datetime object into a
> DATETIME column, the microsecond portion is rejected, but the rest
succeeds,
> so the object is stored to the nearest second.
I had the opportunity to try this with pyodbc, and it does not have the same
problem.
I switched on odbc tracing while executing the following commands, using
both pyodbc and ceODBC.
>>>cur.execute('CREATE TABLE fmtemp (acno INT, dtm DATETIME)')
>>>now = datetime.datetime.now()
>>>now
datetime.datetime(2012, 5, 12, 9, 5, 10, 312000)
>>>cur.execute('INSERT INTO fmtemp VALUES (?, ?)', (1, now))
When I execute 'SELECT * FROM fmtemp', I get the following result -
ceODBC - [(1, datetime.datetime(2012, 5, 12, 9, 5, 10))]
pyodbc - [(1, datetime.datetime(2012, 5, 12, 9, 5, 10, 313000))]
Attached are the sql logs - one each for CREATE and INSERT. I don't
understand them, but there are some notable differences, particularly the
following.
When inserting the integer 1 -
[ceODBC]
SWORD 1 <SQL_PARAM_INPUT>
SWORD 4 <SQL_C_LONG>
SWORD 4 <SQL_INTEGER>
[pyodbc]
SWORD 1 <SQL_PARAM_INPUT>
SWORD -25 <SQL_C_SBIGINT>
SWORD -5 <SQL_BIGINT>
When inserting the datatime object -
[ceODBC]
SWORD 1 <SQL_PARAM_INPUT>
SWORD 93 <SQL_C_TYPE_TIMESTAMP>
SWORD 93 <SQL_TYPE_TIMESTAMP>
[pyodbc]
SWORD 1 <SQL_PARAM_INPUT>
SWORD 11 <SQL_C_TIMESTAMP>
SWORD 11 <SQL_TIMESTAMP>
Any comments will be appreciated.
Thanks
Frank Millman
|
|
From: Frank M. <fr...@ch...> - 2012-04-29 08:36:34
|
Hi all
I am using MS Sql Server 2005, python 3.2.2, and ceODBC 2.0.1.
My problem is with Sql Server, not with ceODBC, but I thought I would ask
here in case someone has figured out a workaround.
Python's datetime.datetime object uses a precision of microseconds. Sql
Server's DATETIME type only uses a precision of milliseconds (to the
nearest 3.33ms).
When I try to insert a datetime.datetime object into a DATETIME column, the
microsecond portion is rejected, but the rest succeeds, so the object is
stored to the nearest second.
One possible workaround is, instead of inserting the datetime object
directly, use the following -
dtm = dtm.isoformat(sep=' ')[:23]
This converts it to a string, and strips off the last three digits of the
microseconds, turning them into milliseconds. It works, but it is not
elegant, and it is quite disruptive to my existing code.
Does anyone have any better suggestions?
Thanks
Frank Millman
P.S. I believe that Sql Server 2008 has a new datetime type that stores
microseconds, but I would prefer to maintain compatibility with 2005.
|
|
From: Anthony T. <ant...@gm...> - 2011-10-15 20:54:10
|
What is ceODBC? ceODBC is a Python extension module that enables access to databases using the ODBC API and conforms to the Python database API 2.0 specifications with a few additions. I have tested this on Windows against SQL Server, Access, dBASE and Oracle and others have reported success on more obscure drivers. On Linux I have tested this against PostgreSQL and MySQL. Where do I get it? http://ceodbc.sourceforge.net What's new? 1) Removed memory leak that occurred when binding parameters to a cursor; thanks to Robert Ritchie and Don Reid for discovering this. 2) Remove the password from the DSN in order to eliminate potential security leaks. 3) Improve performance when logging is disabled or not at level DEBUG by avoiding the entire attempt to log bind variable values. 4) Use the size value rather than the length value when defining result set variables since the length value is for the length of the column name; thanks to Heran Quan for the patch. 5) Added support for Python 3.2. |
|
From: Neil B. <nei...@gm...> - 2011-09-30 15:54:30
|
Hi, Still can't get ceODBC to build with 64 bit Python3.2.2 on Ubuntu 11.04 I get this message now: gcc -pthread -shared build/temp.linux-x86_64-3.2/ceODBC.o -L. -lodbc -lpython3.2m -o build/lib.linux-x86_64-3.2/ceODBC.cpython-32m.so /usr/bin/ld: /usr/lib64/libpython3.2m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC /usr/lib64/libpython3.2m.a: could not read symbols: Bad value I understand that this is usually caused by python not being built with shared libraries but I built it using --enable-shared. > ------------------------------------------------------------------- > > Message: 1 > Date: Mon, 26 Sep 2011 17:16:42 +0100 > From: Neil Beddoe <nei...@gm...> > Subject: [ceodbc-users] Python 3.2.2 > To: ceo...@li... > Message-ID: <1317053802.1918.18.camel@neil-ThinkPad-X220> > Content-Type: text/plain; charset="UTF-8" > > Hi, > > I was getting a file not found error for -lpython3.2 when trying to > build ceODBC with Python 3.2.2 on Ubuntu 64 bit 11.04 so I created the > following link: > > libpython3.2m.a -> /usr/local/Python3.2.2/lib/libpython3.2m.a > > Now I get this: > > /usr/bin/ld: /usr/lib64/libpython3.2m.a(abstract.o): relocation > R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when > making a shared object; recompile with -fPIC > /usr/lib64/libpython3.2m.a: could not read symbols: Bad value > > My Python's built with --enable-shared. > > Neil > > > > > > > ------------------------------ > > Message: 2 > Date: Mon, 26 Sep 2011 23:58:35 +0100 > From: Neil Beddoe <nei...@gm...> > Subject: Re: [ceodbc-users] Python 3.2.2 > To: ceo...@li... > Message-ID: <1317077915.9546.9.camel@neil-ThinkPad-X220> > Content-Type: text/plain; charset="UTF-8" > > I managed to fix this. I'd created the wrong symlink. I case anyone > else comes across the problem, the library you need is > /YOUR_PYTHON_3_DIRECTORY/lib/python3.2/config-3.2m/libpython3.2m.a > > On Mon, 2011-09-26 at 17:16 +0100, Neil Beddoe wrote: > > Hi, > > > > I was getting a file not found error for -lpython3.2 when trying to > > build ceODBC with Python 3.2.2 on Ubuntu 64 bit 11.04 so I created the > > following link: > > > > libpython3.2m.a -> /usr/local/Python3.2.2/lib/libpython3.2m.a > > > > Now I get this: > > > > /usr/bin/ld: /usr/lib64/libpython3.2m.a(abstract.o): relocation > > R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when > > making a shared object; recompile with -fPIC > > /usr/lib64/libpython3.2m.a: could not read symbols: Bad value > > > > My Python's built with --enable-shared. > > > > Neil > > > > > > > > > > > > ------------------------------ > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > > ------------------------------ > > _______________________________________________ > ceodbc-users mailing list > ceo...@li... > https://lists.sourceforge.net/lists/listinfo/ceodbc-users > > > End of ceodbc-users Digest, Vol 14, Issue 1 > ******************************************* |
|
From: Neil B. <nei...@gm...> - 2011-09-26 22:58:45
|
I managed to fix this. I'd created the wrong symlink. I case anyone else comes across the problem, the library you need is /YOUR_PYTHON_3_DIRECTORY/lib/python3.2/config-3.2m/libpython3.2m.a On Mon, 2011-09-26 at 17:16 +0100, Neil Beddoe wrote: > Hi, > > I was getting a file not found error for -lpython3.2 when trying to > build ceODBC with Python 3.2.2 on Ubuntu 64 bit 11.04 so I created the > following link: > > libpython3.2m.a -> /usr/local/Python3.2.2/lib/libpython3.2m.a > > Now I get this: > > /usr/bin/ld: /usr/lib64/libpython3.2m.a(abstract.o): relocation > R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when > making a shared object; recompile with -fPIC > /usr/lib64/libpython3.2m.a: could not read symbols: Bad value > > My Python's built with --enable-shared. > > Neil > > > |
|
From: Neil B. <nei...@gm...> - 2011-09-26 16:16:51
|
Hi, I was getting a file not found error for -lpython3.2 when trying to build ceODBC with Python 3.2.2 on Ubuntu 64 bit 11.04 so I created the following link: libpython3.2m.a -> /usr/local/Python3.2.2/lib/libpython3.2m.a Now I get this: /usr/bin/ld: /usr/lib64/libpython3.2m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC /usr/lib64/libpython3.2m.a: could not read symbols: Bad value My Python's built with --enable-shared. Neil |
|
From: Carl K. <ca...@pe...> - 2011-06-23 17:05:20
|
Profiler - yeah, that.
I wouldn't mind seeing the traffic that is causing this error. but
really for curiosity sake, I have no plans to use it any time soon.
On Thu, Jun 23, 2011 at 9:54 AM, Jon Ludena <jo...@dm...> wrote:
> Thanks for the suggestion; I'll give it a try. I think it's called SQL
> Server Profiler.
>
> Jon
>
> -----Original Message-----
> From: cfk...@gm... [mailto:cfk...@gm...] On Behalf Of Carl
> Karsten
> Sent: Wednesday, June 22, 2011 1:33 PM
> To: Anthony Tuininga
> Cc: jo...@dm...; ceo...@li...
> Subject: Re: [ceodbc-users] Problems Calling a Stored Procedure with
> cursor.callproc or cursor.execdirect
>
> I will also chime in with: use server trace (or whatever it's called, I
> used it with ms sql server 2000, and I think they call it something else
> now.) very helpfull to see what the server got according to the server, not
> what you think you are sending.
>
> On Wed, Jun 22, 2011 at 1:25 PM, Anthony Tuininga
> <ant...@gm...> wrote:
>> I have tried this directly and all appears to be well. Note that I am
>> using the "Sql Server" driver and not the "SqlServer" driver -- not
>> the lack of a space. I'm not sure if this has any bearing or not but
>> thought I would mention it. If you can narrow this down further that
>> would be helpful. Thanks.
>>
>> See the documentation for help on the execdirect() method. If that is
>> insufficent, let me know. Thanks.
>>
>> Anthony
>>
>> On Thu, Jun 16, 2011 at 10:26 AM, Jon Ludena <jo...@dm...> wrote:
>>> I am having a problem calling a stored procedure in sql server using
>>> the cursor.callproc(). The procedure runs but exits prematurely. If I
>>> run this procedure directly from sql I get the desired results (in
>>> this case 278 rows inserted into the desired table) but when I call
>>> from python I only get 31 rows and then the program ends. I tried
>>> using the cursor.execdirect() but I keep getting Database Errors
>>> (improper syntax). Does anyone know the required arguments/parameters
>>> for the exedirect() call or what might be causing the stored procedure to
> exit prematurely?
>>>
>>> Here is the python code:
>>>
>>>
>>>
>>> import ceODBC
>>> connect=ceODBC.connect("""DSN=mydatabase;SERVER=xxx.xxx.x.xxx;
>>> DRIVER={SQLServer};UID=user;PWD=password""", autocommit= True) cursor
>>> = connect.cursor() cursor.execute("""
>>> CREATE TABLE mydatabase.dbo.Vision_TempTable
>>> (
>>> CustId bigint,
>>> PayProcId int,
>>> WebUserId bigint,
>>> SubTypeId bigint,
>>> PayAmt decimal(18,2),
>>> Paydate datetime,
>>> PayType varchar(1),
>>> DateCreated datetime,
>>> PayStatus varchar(1),
>>> Account varchar(30),
>>> V_Account varchar(30)
>>> )""")#Create a temp table which will be used in
>>> the SP insert
>>> connect.commit()
>>> f=open('F:/clients/UTA/Vision/Data/ExternalPay_Data/lbox.txt')
>>> CUST_ID=44
>>> PAYPROCID=4
>>> SUBTYPE_ID=64
>>> WEBUSER_ID=2432
>>> PAYTYPE='C'
>>> PAYSTATUS='J'
>>> for line in f: #parse a text file and insert values into temp table I
>>> just created
>>> lineLength=len(line.strip())
>>> if lineLength>=49:
>>> visionAccount=int(line[10:17])
>>> visionAccount=str(visionAccount)
>>> recipientID=line[17:29]
>>> invoiceAmount=line[31:39]
>>> invoiceAmount=float(invoiceAmount)
>>> pmtType=line[39:41]#make sure it will always be ck
>>> pmtDate=line[45:47]+'/'+line[47:49]+'/'+line[41:45]
>>> cursor.execute("""INSERT INTO mydatabase.dbo.Vision_TempTable
>>>
>>> (CustId,PayProcId,WebUserId,SubTypeId,PayAmt,Paydate,
>>>
>>> PayType,DateCreated,PayStatus,Account,V_Account)
>>> VALUES
>>> (?,?,?,?,?,?,?,GETDATE(),?,?,?)""",
>>> CUST_ID,PAYPROCID,WEBUSER_ID,SUBTYPE_ID,
>>>
>>> invoiceAmount,pmtDate,PAYTYPE,PAYSTATUS,recipientID,visionAccount)
>>>
>>> connect.commit()
>>> cursor.callproc("mydatabase.dbo.VisionExternalPMTS")# turn over
>>> control to SP
>>>
>>> f.close()
>>> connect.close()
>>> print('Done')
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>>
>>> Jon Ludena
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> --------- EditLive Enterprise is the world's most technically
>>> advanced content authoring tool. Experience the power of Track
>>> Changes, Inline Image Editing and ensure content is compliant with
>>> Accessibility Checking.
>>> http://p.sf.net/sfu/ephox-dev2dev
>>> _______________________________________________
>>> ceodbc-users mailing list
>>> ceo...@li...
>>> https://lists.sourceforge.net/lists/listinfo/ceodbc-users
>>>
>>>
>>
>> ----------------------------------------------------------------------
>> -------- Simplify data backup and recovery for your virtual
>> environment with vRanger.
>> Installation's a snap, and flexible recovery options mean your data is
>> safe, secure and there when you need it. Data protection magic?
>> Nope - It's vRanger. Get your free trial download today.
>> http://p.sf.net/sfu/quest-sfdev2dev
>> _______________________________________________
>> ceodbc-users mailing list
>> ceo...@li...
>> https://lists.sourceforge.net/lists/listinfo/ceodbc-users
>>
>
>
>
> --
> Carl K
>
>
--
Carl K
|
|
From: Anthony T. <ant...@gm...> - 2011-06-23 16:30:05
|
cursor.execdirect() only accepts a statement and it is expected to be
in the format that the target database accepts. In this case you can
do this:
cursor.execdirect("EXEC VisionExternalPMTS")
OR
cursor.execdirect("VisionExternalPMTS")
Both appear to work just fine. I doubt that this will help you much, though. :-(
Anthony
On Thu, Jun 23, 2011 at 8:49 AM, Jon Ludena <jo...@dm...> wrote:
> I am also using the "Sql Server" driver. I looked at this url
> http://ceodbc.sourceforge.net/html/cursor.html and read the documentation.
> Can you please explain the arguments/syntax for the execdirect ()? All that
> is on the site is "Cursor.execdirect(statement)". Can you please give me an
> example of how you called the stored procedure using this method, so I can
> try it here on my end?
>
> Thanks
> Jon
>
> -----Original Message-----
> From: Anthony Tuininga [mailto:ant...@gm...]
> Sent: Wednesday, June 22, 2011 1:26 PM
> To: jo...@dm...
> Cc: ceo...@li...
> Subject: Re: [ceodbc-users] Problems Calling a Stored Procedure with
> cursor.callproc or cursor.execdirect
>
> I have tried this directly and all appears to be well. Note that I am using
> the "Sql Server" driver and not the "SqlServer" driver -- not the lack of a
> space. I'm not sure if this has any bearing or not but thought I would
> mention it. If you can narrow this down further that would be helpful.
> Thanks.
>
> See the documentation for help on the execdirect() method. If that is
> insufficent, let me know. Thanks.
>
> Anthony
>
> On Thu, Jun 16, 2011 at 10:26 AM, Jon Ludena <jo...@dm...> wrote:
>> I am having a problem calling a stored procedure in sql server using
>> the cursor.callproc(). The procedure runs but exits prematurely. If I
>> run this procedure directly from sql I get the desired results (in
>> this case 278 rows inserted into the desired table) but when I call
>> from python I only get 31 rows and then the program ends. I tried
>> using the cursor.execdirect() but I keep getting Database Errors
>> (improper syntax). Does anyone know the required arguments/parameters
>> for the exedirect() call or what might be causing the stored procedure to
> exit prematurely?
>>
>> Here is the python code:
>>
>>
>>
>> import ceODBC
>> connect=ceODBC.connect("""DSN=mydatabase;SERVER=xxx.xxx.x.xxx;
>> DRIVER={SQLServer};UID=user;PWD=password""", autocommit= True) cursor
>> = connect.cursor() cursor.execute("""
>> CREATE TABLE mydatabase.dbo.Vision_TempTable
>> (
>> CustId bigint,
>> PayProcId int,
>> WebUserId bigint,
>> SubTypeId bigint,
>> PayAmt decimal(18,2),
>> Paydate datetime,
>> PayType varchar(1),
>> DateCreated datetime,
>> PayStatus varchar(1),
>> Account varchar(30),
>> V_Account varchar(30)
>> )""")#Create a temp table which will be used in
>> the SP insert
>> connect.commit()
>> f=open('F:/clients/UTA/Vision/Data/ExternalPay_Data/lbox.txt')
>> CUST_ID=44
>> PAYPROCID=4
>> SUBTYPE_ID=64
>> WEBUSER_ID=2432
>> PAYTYPE='C'
>> PAYSTATUS='J'
>> for line in f: #parse a text file and insert values into temp table I
>> just created
>> lineLength=len(line.strip())
>> if lineLength>=49:
>> visionAccount=int(line[10:17])
>> visionAccount=str(visionAccount)
>> recipientID=line[17:29]
>> invoiceAmount=line[31:39]
>> invoiceAmount=float(invoiceAmount)
>> pmtType=line[39:41]#make sure it will always be ck
>> pmtDate=line[45:47]+'/'+line[47:49]+'/'+line[41:45]
>> cursor.execute("""INSERT INTO mydatabase.dbo.Vision_TempTable
>>
>> (CustId,PayProcId,WebUserId,SubTypeId,PayAmt,Paydate,
>>
>> PayType,DateCreated,PayStatus,Account,V_Account)
>> VALUES
>> (?,?,?,?,?,?,?,GETDATE(),?,?,?)""",
>> CUST_ID,PAYPROCID,WEBUSER_ID,SUBTYPE_ID,
>>
>> invoiceAmount,pmtDate,PAYTYPE,PAYSTATUS,recipientID,visionAccount)
>>
>> connect.commit()
>> cursor.callproc("mydatabase.dbo.VisionExternalPMTS")# turn over
>> control to SP
>>
>> f.close()
>> connect.close()
>> print('Done')
>>
>>
>>
>> Thanks
>>
>>
>>
>> Jon Ludena
>>
>>
>>
>>
>>
>> ----------------------------------------------------------------------
>> -------- EditLive Enterprise is the world's most technically advanced
>> content authoring tool. Experience the power of Track Changes, Inline
>> Image Editing and ensure content is compliant with Accessibility
>> Checking.
>> http://p.sf.net/sfu/ephox-dev2dev
>> _______________________________________________
>> ceodbc-users mailing list
>> ceo...@li...
>> https://lists.sourceforge.net/lists/listinfo/ceodbc-users
>>
>>
>
>
|
|
From: Jon L. <jo...@dm...> - 2011-06-23 15:57:22
|
Thanks for the suggestion; I'll give it a try. I think it's called SQL
Server Profiler.
Jon
-----Original Message-----
From: cfk...@gm... [mailto:cfk...@gm...] On Behalf Of Carl
Karsten
Sent: Wednesday, June 22, 2011 1:33 PM
To: Anthony Tuininga
Cc: jo...@dm...; ceo...@li...
Subject: Re: [ceodbc-users] Problems Calling a Stored Procedure with
cursor.callproc or cursor.execdirect
I will also chime in with: use server trace (or whatever it's called, I
used it with ms sql server 2000, and I think they call it something else
now.) very helpfull to see what the server got according to the server, not
what you think you are sending.
On Wed, Jun 22, 2011 at 1:25 PM, Anthony Tuininga
<ant...@gm...> wrote:
> I have tried this directly and all appears to be well. Note that I am
> using the "Sql Server" driver and not the "SqlServer" driver -- not
> the lack of a space. I'm not sure if this has any bearing or not but
> thought I would mention it. If you can narrow this down further that
> would be helpful. Thanks.
>
> See the documentation for help on the execdirect() method. If that is
> insufficent, let me know. Thanks.
>
> Anthony
>
> On Thu, Jun 16, 2011 at 10:26 AM, Jon Ludena <jo...@dm...> wrote:
>> I am having a problem calling a stored procedure in sql server using
>> the cursor.callproc(). The procedure runs but exits prematurely. If I
>> run this procedure directly from sql I get the desired results (in
>> this case 278 rows inserted into the desired table) but when I call
>> from python I only get 31 rows and then the program ends. I tried
>> using the cursor.execdirect() but I keep getting Database Errors
>> (improper syntax). Does anyone know the required arguments/parameters
>> for the exedirect() call or what might be causing the stored procedure to
exit prematurely?
>>
>> Here is the python code:
>>
>>
>>
>> import ceODBC
>> connect=ceODBC.connect("""DSN=mydatabase;SERVER=xxx.xxx.x.xxx;
>> DRIVER={SQLServer};UID=user;PWD=password""", autocommit= True) cursor
>> = connect.cursor() cursor.execute("""
>> CREATE TABLE mydatabase.dbo.Vision_TempTable
>> (
>> CustId bigint,
>> PayProcId int,
>> WebUserId bigint,
>> SubTypeId bigint,
>> PayAmt decimal(18,2),
>> Paydate datetime,
>> PayType varchar(1),
>> DateCreated datetime,
>> PayStatus varchar(1),
>> Account varchar(30),
>> V_Account varchar(30)
>> )""")#Create a temp table which will be used in
>> the SP insert
>> connect.commit()
>> f=open('F:/clients/UTA/Vision/Data/ExternalPay_Data/lbox.txt')
>> CUST_ID=44
>> PAYPROCID=4
>> SUBTYPE_ID=64
>> WEBUSER_ID=2432
>> PAYTYPE='C'
>> PAYSTATUS='J'
>> for line in f: #parse a text file and insert values into temp table I
>> just created
>> lineLength=len(line.strip())
>> if lineLength>=49:
>> visionAccount=int(line[10:17])
>> visionAccount=str(visionAccount)
>> recipientID=line[17:29]
>> invoiceAmount=line[31:39]
>> invoiceAmount=float(invoiceAmount)
>> pmtType=line[39:41]#make sure it will always be ck
>> pmtDate=line[45:47]+'/'+line[47:49]+'/'+line[41:45]
>> cursor.execute("""INSERT INTO mydatabase.dbo.Vision_TempTable
>>
>> (CustId,PayProcId,WebUserId,SubTypeId,PayAmt,Paydate,
>>
>> PayType,DateCreated,PayStatus,Account,V_Account)
>> VALUES
>> (?,?,?,?,?,?,?,GETDATE(),?,?,?)""",
>> CUST_ID,PAYPROCID,WEBUSER_ID,SUBTYPE_ID,
>>
>> invoiceAmount,pmtDate,PAYTYPE,PAYSTATUS,recipientID,visionAccount)
>>
>> connect.commit()
>> cursor.callproc("mydatabase.dbo.VisionExternalPMTS")# turn over
>> control to SP
>>
>> f.close()
>> connect.close()
>> print('Done')
>>
>>
>>
>> Thanks
>>
>>
>>
>> Jon Ludena
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> --------- EditLive Enterprise is the world's most technically
>> advanced content authoring tool. Experience the power of Track
>> Changes, Inline Image Editing and ensure content is compliant with
>> Accessibility Checking.
>> http://p.sf.net/sfu/ephox-dev2dev
>> _______________________________________________
>> ceodbc-users mailing list
>> ceo...@li...
>> https://lists.sourceforge.net/lists/listinfo/ceodbc-users
>>
>>
>
> ----------------------------------------------------------------------
> -------- Simplify data backup and recovery for your virtual
> environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is
> safe, secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> ceodbc-users mailing list
> ceo...@li...
> https://lists.sourceforge.net/lists/listinfo/ceodbc-users
>
--
Carl K
|
|
From: Jon L. <jo...@dm...> - 2011-06-23 15:47:28
|
I am also using the "Sql Server" driver. I looked at this url http://ceodbc.sourceforge.net/html/cursor.html and read the documentation. Can you please explain the arguments/syntax for the execdirect ()? All that is on the site is "Cursor.execdirect(statement)". Can you please give me an example of how you called the stored procedure using this method, so I can try it here on my end? Thanks Jon -----Original Message----- From: Anthony Tuininga [mailto:ant...@gm...] Sent: Wednesday, June 22, 2011 1:26 PM To: jo...@dm... Cc: ceo...@li... Subject: Re: [ceodbc-users] Problems Calling a Stored Procedure with cursor.callproc or cursor.execdirect I have tried this directly and all appears to be well. Note that I am using the "Sql Server" driver and not the "SqlServer" driver -- not the lack of a space. I'm not sure if this has any bearing or not but thought I would mention it. If you can narrow this down further that would be helpful. Thanks. See the documentation for help on the execdirect() method. If that is insufficent, let me know. Thanks. Anthony On Thu, Jun 16, 2011 at 10:26 AM, Jon Ludena <jo...@dm...> wrote: > I am having a problem calling a stored procedure in sql server using > the cursor.callproc(). The procedure runs but exits prematurely. If I > run this procedure directly from sql I get the desired results (in > this case 278 rows inserted into the desired table) but when I call > from python I only get 31 rows and then the program ends. I tried > using the cursor.execdirect() but I keep getting Database Errors > (improper syntax). Does anyone know the required arguments/parameters > for the exedirect() call or what might be causing the stored procedure to exit prematurely? > > Here is the python code: > > > > import ceODBC > connect=ceODBC.connect("""DSN=mydatabase;SERVER=xxx.xxx.x.xxx; > DRIVER={SQLServer};UID=user;PWD=password""", autocommit= True) cursor > = connect.cursor() cursor.execute(""" > CREATE TABLE mydatabase.dbo.Vision_TempTable > ( > CustId bigint, > PayProcId int, > WebUserId bigint, > SubTypeId bigint, > PayAmt decimal(18,2), > Paydate datetime, > PayType varchar(1), > DateCreated datetime, > PayStatus varchar(1), > Account varchar(30), > V_Account varchar(30) > )""")#Create a temp table which will be used in > the SP insert > connect.commit() > f=open('F:/clients/UTA/Vision/Data/ExternalPay_Data/lbox.txt') > CUST_ID=44 > PAYPROCID=4 > SUBTYPE_ID=64 > WEBUSER_ID=2432 > PAYTYPE='C' > PAYSTATUS='J' > for line in f: #parse a text file and insert values into temp table I > just created > lineLength=len(line.strip()) > if lineLength>=49: > visionAccount=int(line[10:17]) > visionAccount=str(visionAccount) > recipientID=line[17:29] > invoiceAmount=line[31:39] > invoiceAmount=float(invoiceAmount) > pmtType=line[39:41]#make sure it will always be ck > pmtDate=line[45:47]+'/'+line[47:49]+'/'+line[41:45] > cursor.execute("""INSERT INTO mydatabase.dbo.Vision_TempTable > > (CustId,PayProcId,WebUserId,SubTypeId,PayAmt,Paydate, > > PayType,DateCreated,PayStatus,Account,V_Account) > VALUES > (?,?,?,?,?,?,?,GETDATE(),?,?,?)""", > CUST_ID,PAYPROCID,WEBUSER_ID,SUBTYPE_ID, > > invoiceAmount,pmtDate,PAYTYPE,PAYSTATUS,recipientID,visionAccount) > > connect.commit() > cursor.callproc("mydatabase.dbo.VisionExternalPMTS")# turn over > control to SP > > f.close() > connect.close() > print('Done') > > > > Thanks > > > > Jon Ludena > > > > > > ---------------------------------------------------------------------- > -------- EditLive Enterprise is the world's most technically advanced > content authoring tool. Experience the power of Track Changes, Inline > Image Editing and ensure content is compliant with Accessibility > Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > ceodbc-users mailing list > ceo...@li... > https://lists.sourceforge.net/lists/listinfo/ceodbc-users > > |
|
From: Carl K. <ca...@pe...> - 2011-06-22 18:33:15
|
I will also chime in with: use server trace (or whatever it's called,
I used it with ms sql server 2000, and I think they call it something
else now.) very helpfull to see what the server got according to the
server, not what you think you are sending.
On Wed, Jun 22, 2011 at 1:25 PM, Anthony Tuininga
<ant...@gm...> wrote:
> I have tried this directly and all appears to be well. Note that I am
> using the "Sql Server" driver and not the "SqlServer" driver -- not
> the lack of a space. I'm not sure if this has any bearing or not but
> thought I would mention it. If you can narrow this down further that
> would be helpful. Thanks.
>
> See the documentation for help on the execdirect() method. If that is
> insufficent, let me know. Thanks.
>
> Anthony
>
> On Thu, Jun 16, 2011 at 10:26 AM, Jon Ludena <jo...@dm...> wrote:
>> I am having a problem calling a stored procedure in sql server using the
>> cursor.callproc(). The procedure runs but exits prematurely. If I run this
>> procedure directly from sql I get the desired results (in this case 278 rows
>> inserted into the desired table) but when I call from python I only get 31
>> rows and then the program ends. I tried using the cursor.execdirect() but I
>> keep getting Database Errors (improper syntax). Does anyone know the
>> required arguments/parameters for the exedirect() call or what might be
>> causing the stored procedure to exit prematurely?
>>
>> Here is the python code:
>>
>>
>>
>> import ceODBC
>> connect=ceODBC.connect("""DSN=mydatabase;SERVER=xxx.xxx.x.xxx;
>> DRIVER={SQLServer};UID=user;PWD=password""", autocommit= True)
>> cursor = connect.cursor()
>> cursor.execute("""
>> CREATE TABLE mydatabase.dbo.Vision_TempTable
>> (
>> CustId bigint,
>> PayProcId int,
>> WebUserId bigint,
>> SubTypeId bigint,
>> PayAmt decimal(18,2),
>> Paydate datetime,
>> PayType varchar(1),
>> DateCreated datetime,
>> PayStatus varchar(1),
>> Account varchar(30),
>> V_Account varchar(30)
>> )""")#Create a temp table which will be used in the SP
>> insert
>> connect.commit()
>> f=open('F:/clients/UTA/Vision/Data/ExternalPay_Data/lbox.txt')
>> CUST_ID=44
>> PAYPROCID=4
>> SUBTYPE_ID=64
>> WEBUSER_ID=2432
>> PAYTYPE='C'
>> PAYSTATUS='J'
>> for line in f: #parse a text file and insert values into temp table I just
>> created
>> lineLength=len(line.strip())
>> if lineLength>=49:
>> visionAccount=int(line[10:17])
>> visionAccount=str(visionAccount)
>> recipientID=line[17:29]
>> invoiceAmount=line[31:39]
>> invoiceAmount=float(invoiceAmount)
>> pmtType=line[39:41]#make sure it will always be ck
>> pmtDate=line[45:47]+'/'+line[47:49]+'/'+line[41:45]
>> cursor.execute("""INSERT INTO mydatabase.dbo.Vision_TempTable
>>
>> (CustId,PayProcId,WebUserId,SubTypeId,PayAmt,Paydate,
>>
>> PayType,DateCreated,PayStatus,Account,V_Account)
>> VALUES
>> (?,?,?,?,?,?,?,GETDATE(),?,?,?)""",
>> CUST_ID,PAYPROCID,WEBUSER_ID,SUBTYPE_ID,
>>
>> invoiceAmount,pmtDate,PAYTYPE,PAYSTATUS,recipientID,visionAccount)
>>
>> connect.commit()
>> cursor.callproc("mydatabase.dbo.VisionExternalPMTS")# turn over control to
>> SP
>>
>> f.close()
>> connect.close()
>> print('Done')
>>
>>
>>
>> Thanks
>>
>>
>>
>> Jon Ludena
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> EditLive Enterprise is the world's most technically advanced content
>> authoring tool. Experience the power of Track Changes, Inline Image
>> Editing and ensure content is compliant with Accessibility Checking.
>> http://p.sf.net/sfu/ephox-dev2dev
>> _______________________________________________
>> ceodbc-users mailing list
>> ceo...@li...
>> https://lists.sourceforge.net/lists/listinfo/ceodbc-users
>>
>>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> ceodbc-users mailing list
> ceo...@li...
> https://lists.sourceforge.net/lists/listinfo/ceodbc-users
>
--
Carl K
|
|
From: Anthony T. <ant...@gm...> - 2011-06-22 18:25:56
|
I have tried this directly and all appears to be well. Note that I am
using the "Sql Server" driver and not the "SqlServer" driver -- not
the lack of a space. I'm not sure if this has any bearing or not but
thought I would mention it. If you can narrow this down further that
would be helpful. Thanks.
See the documentation for help on the execdirect() method. If that is
insufficent, let me know. Thanks.
Anthony
On Thu, Jun 16, 2011 at 10:26 AM, Jon Ludena <jo...@dm...> wrote:
> I am having a problem calling a stored procedure in sql server using the
> cursor.callproc(). The procedure runs but exits prematurely. If I run this
> procedure directly from sql I get the desired results (in this case 278 rows
> inserted into the desired table) but when I call from python I only get 31
> rows and then the program ends. I tried using the cursor.execdirect() but I
> keep getting Database Errors (improper syntax). Does anyone know the
> required arguments/parameters for the exedirect() call or what might be
> causing the stored procedure to exit prematurely?
>
> Here is the python code:
>
>
>
> import ceODBC
> connect=ceODBC.connect("""DSN=mydatabase;SERVER=xxx.xxx.x.xxx;
> DRIVER={SQLServer};UID=user;PWD=password""", autocommit= True)
> cursor = connect.cursor()
> cursor.execute("""
> CREATE TABLE mydatabase.dbo.Vision_TempTable
> (
> CustId bigint,
> PayProcId int,
> WebUserId bigint,
> SubTypeId bigint,
> PayAmt decimal(18,2),
> Paydate datetime,
> PayType varchar(1),
> DateCreated datetime,
> PayStatus varchar(1),
> Account varchar(30),
> V_Account varchar(30)
> )""")#Create a temp table which will be used in the SP
> insert
> connect.commit()
> f=open('F:/clients/UTA/Vision/Data/ExternalPay_Data/lbox.txt')
> CUST_ID=44
> PAYPROCID=4
> SUBTYPE_ID=64
> WEBUSER_ID=2432
> PAYTYPE='C'
> PAYSTATUS='J'
> for line in f: #parse a text file and insert values into temp table I just
> created
> lineLength=len(line.strip())
> if lineLength>=49:
> visionAccount=int(line[10:17])
> visionAccount=str(visionAccount)
> recipientID=line[17:29]
> invoiceAmount=line[31:39]
> invoiceAmount=float(invoiceAmount)
> pmtType=line[39:41]#make sure it will always be ck
> pmtDate=line[45:47]+'/'+line[47:49]+'/'+line[41:45]
> cursor.execute("""INSERT INTO mydatabase.dbo.Vision_TempTable
>
> (CustId,PayProcId,WebUserId,SubTypeId,PayAmt,Paydate,
>
> PayType,DateCreated,PayStatus,Account,V_Account)
> VALUES
> (?,?,?,?,?,?,?,GETDATE(),?,?,?)""",
> CUST_ID,PAYPROCID,WEBUSER_ID,SUBTYPE_ID,
>
> invoiceAmount,pmtDate,PAYTYPE,PAYSTATUS,recipientID,visionAccount)
>
> connect.commit()
> cursor.callproc("mydatabase.dbo.VisionExternalPMTS")# turn over control to
> SP
>
> f.close()
> connect.close()
> print('Done')
>
>
>
> Thanks
>
>
>
> Jon Ludena
>
>
>
>
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> ceodbc-users mailing list
> ceo...@li...
> https://lists.sourceforge.net/lists/listinfo/ceodbc-users
>
>
|
|
From: Jon L. <jo...@dm...> - 2011-06-16 15:24:50
|
I am having a problem calling a stored procedure in sql server using the
cursor.callproc(). The procedure runs but exits prematurely. If I run this
procedure directly from sql I get the desired results (in this case 278 rows
inserted into the desired table) but when I call from python I only get 31
rows and then the program ends. I tried using the cursor.execdirect() but I
keep getting Database Errors (improper syntax). Does anyone know the
required arguments/parameters for the exedirect() call or what might be
causing the stored procedure to exit prematurely?
Here is the python code:
import ceODBC
connect=ceODBC.connect("""DSN=mydatabase;SERVER=xxx.xxx.x.xxx;
DRIVER={SQLServer};UID=user;PWD=password""", autocommit= True)
cursor = connect.cursor()
cursor.execute("""
CREATE TABLE mydatabase.dbo.Vision_TempTable
(
CustId bigint,
PayProcId int,
WebUserId bigint,
SubTypeId bigint,
PayAmt decimal(18,2),
Paydate datetime,
PayType varchar(1),
DateCreated datetime,
PayStatus varchar(1),
Account varchar(30),
V_Account varchar(30)
)""")#Create a temp table which will be used in the SP
insert
connect.commit()
f=open('F:/clients/UTA/Vision/Data/ExternalPay_Data/lbox.txt')
CUST_ID=44
PAYPROCID=4
SUBTYPE_ID=64
WEBUSER_ID=2432
PAYTYPE='C'
PAYSTATUS='J'
for line in f: #parse a text file and insert values into temp table I just
created
lineLength=len(line.strip())
if lineLength>=49:
visionAccount=int(line[10:17])
visionAccount=str(visionAccount)
recipientID=line[17:29]
invoiceAmount=line[31:39]
invoiceAmount=float(invoiceAmount)
pmtType=line[39:41]#make sure it will always be ck
pmtDate=line[45:47]+'/'+line[47:49]+'/'+line[41:45]
cursor.execute("""INSERT INTO mydatabase.dbo.Vision_TempTable
(CustId,PayProcId,WebUserId,SubTypeId,PayAmt,Paydate,
PayType,DateCreated,PayStatus,Account,V_Account)
VALUES
(?,?,?,?,?,?,?,GETDATE(),?,?,?)""",
CUST_ID,PAYPROCID,WEBUSER_ID,SUBTYPE_ID,
invoiceAmount,pmtDate,PAYTYPE,PAYSTATUS,recipientID,visionAccount)
connect.commit()
cursor.callproc("mydatabase.dbo.VisionExternalPMTS")# turn over control to
SP
f.close()
connect.close()
print('Done')
Thanks
Jon Ludena
|
|
From: Dan S. <dst...@gm...> - 2010-10-07 20:20:34
|
More information: 1. The same code appears to be working well on Windows XP - 100 tests out of 100 succeeded. On Ubuntu 0 tests have succeeded. 2. I'm using Python 2.6.5 on both Ubuntu and XP SP3 Thanks again. On Thu, Oct 7, 2010 at 12:57 PM, Dan Stromberg <dst...@gm...>wrote: > > I'm evaluating ceODBC as an alternative to pyodbc and pywin32 odbc. > > I have pyodbc and pywin32's odbc working, but pyodbc is a bit slow, and > pywin32's odbc just isn't as nice to use as the more recent modules. > > Anyway, when I try to run a simple query using ceODBC: > > select top(1000) * from <database> > > > I get one of two errors back. > > The one I get the most is: > > self.cursor.close() > > ceODBC.DatabaseError: no diagnostic message text available > > > ...but once in a while I get the following: > > for rows_retrieved, row in enumerate(self.cursor): > > ceODBC.InterfaceError: not a query > > > I'm a little concerned there may be some sort of race condition in ceODBC > at this point. > > Obligatory version information: > > 1. Running on Ubuntu 10.04 with latest patches > 2. FreeTDS 0.82-6build1 > 3. unixodbc 2.2.11-21 > 4. Running against a SQL Server database (I don't have the version of > the server readily available to me, but it's on Windows 7 of unknown service > pack) > > Thanks for making ceODBC available! > > |
|
From: Dan S. <dst...@gm...> - 2010-10-07 19:57:39
|
I'm evaluating ceODBC as an alternative to pyodbc and pywin32 odbc.
I have pyodbc and pywin32's odbc working, but pyodbc is a bit slow, and
pywin32's odbc just isn't as nice to use as the more recent modules.
Anyway, when I try to run a simple query using ceODBC:
select top(1000) * from <database>
I get one of two errors back.
The one I get the most is:
self.cursor.close()
ceODBC.DatabaseError: no diagnostic message text available
...but once in a while I get the following:
for rows_retrieved, row in enumerate(self.cursor):
ceODBC.InterfaceError: not a query
I'm a little concerned there may be some sort of race condition in ceODBC at
this point.
Obligatory version information:
1. Running on Ubuntu 10.04 with latest patches
2. FreeTDS 0.82-6build1
3. unixodbc 2.2.11-21
4. Running against a SQL Server database (I don't have the version of the
server readily available to me, but it's on Windows 7 of unknown service
pack)
Thanks for making ceODBC available!
|
|
From: Thomas L. W. <mr...@gm...> - 2010-09-23 23:06:26
|
Thanks again, this time it's all playing :) I just needed unixodbc-dev via aptitude. Thomas On Fri, Sep 24, 2010 at 12:39 AM, Anthony Tuininga < ant...@gm...> wrote: > You're welcome. > > You need to have unixODBC-dev or something similar as well. After that > you should be good. > > Anthony > > On Thu, Sep 23, 2010 at 4:31 PM, Thomas Larsen Wessel <mr...@gm...> > wrote: > > Thanks Anthony. So I installed python-dev via apt-get, and I think that > > helped ... But well, now I have different errors. > > > > First 10 lines of stderr, after installation python-dev: > > ceODBC.c:13:17: error: sql.h: No such file or directory > > ceODBC.c:14:22: error: sqlucode.h: No such file or directory > > In file included from ceODBC.c:169: > > Error.c:15: error: expected specifier-qualifier-list before ‘SQLSMALLINT’ > > Error.c:116: error: expected declaration specifiers or ‘...’ before > > ‘SQLRETURN’ > > Error.c: In function ‘Error_CheckForError’: > > Error.c:120: error: ‘SQLCHAR’ undeclared (first use in this function) > > Error.c:120: error: (Each undeclared identifier is reported only once > > Error.c:120: error: for each function it appears in.) > > > > I have searched my computer for these sql.h and sqlucode.h, but they are > not > > there. I think the errors are all coming from the gcc. > > > > Should I get these files from somewhere, or is the problem because of > smth. > > else? > > > > Thomas > > > > > > On Thu, Sep 23, 2010 at 11:42 PM, Anthony Tuininga > > <ant...@gm...> wrote: > >> > >> Hi, > >> > >> You are missing the necessary development packages for Python and > >> ODBC. The lines that complain about missing include files are the ones > >> that are important. Once you install those packages those errors > >> should go away and you should be good to go. > >> > >> Anthony > >> > >> On Thu, Sep 23, 2010 at 1:50 PM, Thomas Larsen Wessel < > mr...@gm...> > >> wrote: > >> > Hi. I am running Ubuntu 10.04, with Python 2.6.5. > >> > > >> > I am looking for a db2 driver for Python, and found the list: > >> > http://wiki.python.org/moin/DB2. I have tried all of the drivers on > the > >> > site, and they all need installation with smth. like "python setup.py > >> > build", "python setup.py install". And they all fail with some gcc > >> > error! > >> > > >> > Python works fine for all the other things I have tried, but it is the > >> > first > >> > time I install a python module in another way than using apt-get. > >> > > >> > The errors I get are many pages long, and I do not know what is > >> > important > >> > from there, so I supply the first 10 lines and the last ten lines. > >> > > >> > First ten lines or stderr: > >> > ceODBC.c:6:20: error: Python.h: No such file or directory > >> > ceODBC.c:7:26: error: structmember.h: No such file or directory > >> > ceODBC.c:8:22: error: datetime.h: No such file or directory > >> > ceODBC.c:13:17: error: sql.h: No such file or directory > >> > ceODBC.c:14:22: error: sqlucode.h: No such file or directory > >> > ceODBC.c:98: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > ceODBC.c:99: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > ceODBC.c:100: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > ceODBC.c:101: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > ceODBC.c:102: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > > >> > First ten lines or stderr: > >> > Connection.c:853: error: too many arguments to function > >> > ‘Error_CheckForError’ > >> > ceODBC.c: At top level: > >> > ceODBC.c:178: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > ceODBC.c:204: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > ceODBC.c:214: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > ceODBC.c:223: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘g_ModuleMethods’ > >> > ceODBC.c:253: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ > >> > before > >> > ‘*’ token > >> > ceODBC.c: In function ‘initceODBC’: > >> > ceODBC.c:430: warning: implicit declaration of function > >> > ‘Module_Initialize’ > >> > error: command 'gcc' failed with exit status 1 > >> > > >> > > >> > > >> > Your help is appreciated, > >> > Sincerely, Thomas > >> > > >> > > >> > > >> > > ------------------------------------------------------------------------------ > >> > Nokia and AT&T present the 2010 Calling All Innovators-North America > >> > contest > >> > Create new apps & games for the Nokia N8 for consumers in U.S. and > >> > Canada > >> > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > >> > marketing > >> > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi > Store > >> > http://p.sf.net/sfu/nokia-dev2dev > >> > _______________________________________________ > >> > ceodbc-users mailing list > >> > ceo...@li... > >> > https://lists.sourceforge.net/lists/listinfo/ceodbc-users > >> > > >> > > > > > > > > ------------------------------------------------------------------------------ > > Nokia and AT&T present the 2010 Calling All Innovators-North America > contest > > Create new apps & games for the Nokia N8 for consumers in U.S. and > Canada > > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > marketing > > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > > http://p.sf.net/sfu/nokia-dev2dev > > _______________________________________________ > > ceodbc-users mailing list > > ceo...@li... > > https://lists.sourceforge.net/lists/listinfo/ceodbc-users > > > > > |