473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Python and Sybase

What module is most recommended for accessing Sybase from Python? This
one: http://www.object-craft.com.au/projects/sybase/sybase/ ?

Also, is there any module that provides a generic DB API and can be
hooked to both Sybase and postgresql? This
(http://www.python.org/peps/pep-0249.html) looks pretty old.
Jul 18 '05 #1
18 6718

David> What module is most recommended for accessing Sybase from Python?
David> This one: http://www.object-craft.com.au/projects/sybase/sybase/
David> ?

If I'm not mistaken, I think that's the only one, barring some sort of ODBC
stuff.

David> Also, is there any module that provides a generic DB API and can
David> be hooked to both Sybase and postgresql? This
David> (http://www.python.org/peps/pep-0249.html) looks pretty old.

There hasn't been that much change to how relational databases are accessed
in the time since that PEP was finalized. Do you think something's missing
or was done wrong? If so, I think the db****@python.org list is still alive
and well.

Skip
Jul 18 '05 #2
On Thu, 23 Sep 2004 14:50:04 -0400, David Rysdam <dr*****@ll.mit.edu> wrote:
What module is most recommended for accessing Sybase from Python? This
one: http://www.object-craft.com.au/projects/sybase/sybase/ ?
Object-Craft's is the best one I've found so far.

Also, is there any module that provides a generic DB API and can be
hooked to both Sybase and postgresql? This
(http://www.python.org/peps/pep-0249.html) looks pretty old.


Why would you need that? Python has a DB API, so all you have to do to
change from db to db is the connection string.

conn = Sybase.connection(.....)
conn = otherModules.connection(....)

Everthing else should work the same way.

-Josh
Jul 18 '05 #3
David Rysdam <dr*****@ll.mit.edu> writes:
What module is most recommended for accessing Sybase from Python?
This one: http://www.object-craft.com.au/projects/sybase/sybase/ ?
As far as I know, that's the only one.

Also, is there any module that provides a generic DB API and can be
hooked to both Sybase and postgresql? This
(http://www.python.org/peps/pep-0249.html) looks pretty old.


Not a single module -- why would you want one?

The DB API (version 2) is the standard. The idea of the DB API is to
make it possible to write DB API code that works across multiple
database backends. No need at all for a single module, just a single
standard. Unfortunately, making this work is not entirely trivial:
There are some stupid issues that are the fault of the DB API -- SQL
argument substitution syntax in particular -- and some trickier ones
-- particularly the variations in the capabilities of DBMSes. If you
want your code to work across multiple DBMS backends, you should test
it with those DBMSes from the start. Doing it later is possible but
may be hard work (made less difficult if you keep your DB code
localised).
John
Jul 18 '05 #4
John J. Lee wrote:
David Rysdam <dr*****@ll.mit.edu> writes:
Also, is there any module that provides a generic DB API and can be
hooked to both Sybase and postgresql? This
(http://www.python.org/peps/pep-0249.html) looks pretty old.

Not a single module -- why would you want one?

The DB API (version 2) is the standard. The idea of the DB API is to
make it possible to write DB API code that works across multiple
database backends. No need at all for a single module, just a single
standard. Unfortunately, making this work is not entirely trivial:
There are some stupid issues that are the fault of the DB API -- SQL
argument substitution syntax in particular -- and some trickier ones
-- particularly the variations in the capabilities of DBMSes. If you
want your code to work across multiple DBMS backends, you should test
it with those DBMSes from the start. Doing it later is possible but
may be hard work (made less difficult if you keep your DB code
localised).


Yes, I posted this question before I understood what the DB API was.
Looks good.
Jul 18 '05 #5
David Rysdam <dr*****@ll.mit.edu> writes:
What module is most recommended for accessing Sybase from Python?
This one: http://www.object-craft.com.au/projects/sybase/sybase/ ?


While we're here, is there a free module for accessing SQLServer from
Python? Last I checked this Sybase driver was the only option.
Jul 18 '05 #6
On Fri, 24 Sep 2004 15:45:21 GMT, Nelson Minar <ne****@monkey.org> wrote:
David Rysdam <dr*****@ll.mit.edu> writes:
What module is most recommended for accessing Sybase from Python?
This one: http://www.object-craft.com.au/projects/sybase/sybase/ ?


While we're here, is there a free module for accessing SQLServer from
Python? Last I checked this Sybase driver was the only option.


Pymssql is, but I don't think it's DB API-2.0 compliant.

-Josh
Jul 18 '05 #7
Nelson Minar wrote:
While we're here, is there a free module for accessing SQLServer from
Python? Last I checked this Sybase driver was the only option.


Pywin32 (formerly win32all) has an odbc module which is DB-API 1.0 compliant.

There's also adodbapi, which is DB-API 2.0 compliant.

I haven't used the latter enough to work out if it's reasonably useful. I
don't get on with the former very well, though.

Oh, and non-free there's mxODBC, which also works under unix.

Also from unix someone mentioned a module based on ODBTP, which hasn't yet
surfaced out in the wild.

Moof
Jul 18 '05 #8
[David Rysdam]
What module is most recommended for accessing Sybase from Python?
This one: http://www.object-craft.com.au/projects/sybase/sybase/?

[Nelson Minar] While we're here, is there a free module for accessing SQLServer
from Python? Last I checked this Sybase driver was the only option.
[Josh Close] Pymssql is, but I don't think it's DB API-2.0 compliant.
[Moof] Pywin32 (formerly win32all) has an odbc module which is DB-API 1.0
compliant.

There's also adodbapi, which is DB-API 2.0 compliant.

I haven't used the latter enough to work out if it's reasonably
useful. Idon't get on with the former very well, though.

Oh, and non-free there's mxODBC, which also works under unix.

Also from unix someone mentioned a module based on ODBTP, which
hasn't yet surfaced out in the wild.


Thanks to Josh and Moof for pointing out the other alternatives for
connecting to Sybase and MS-SQLServer.

When looking at the DB-SIG web page, although I can see a list of
database modules there that support the DB-API in its different versions
and levels, I can see no easy way for that list to be updated with the
above sort of invaluable information.

Might it be a good idea to make at least part of the DB-SIG web page a
wiki/moin? A moin works well in the web framework/templating arena, so
perhaps it is also suitable for database modules?

Regards,

Alan.
Jul 18 '05 #9

Alan> When looking at the DB-SIG web page, although I can see a list of
Alan> database modules there that support the DB-API in its different
Alan> versions and levels, I can see no easy way for that list to be
Alan> updated with the above sort of invaluable information.

Alan> Might it be a good idea to make at least part of the DB-SIG web
Alan> page a wiki/moin? A moin works well in the web
Alan> framework/templating arena, so perhaps it is also suitable for
Alan> database modules?

Go ahead and update the Python wiki:

http://www.python.org/moin

culling whatever dynamic information you think approrpriate from the
existing db-sig pages. Note that there are already several pages with
the word "database" in their titles. Search at the bottom of any page to
find them. It's likely one of them will be a better starting place than a
clean sheet of WikiPaper.

Once you have something, let me know and I'll update the topics/data/modules
page to refer to it. It would be extra helpful if you could update a copy
of this page:

http://www.python.org/topics/database/modules.ht

(note the lack of "ml" at the end) and shoot it to me. If so, that will
simplify my job.

Skip
Jul 18 '05 #10
Josh Close <na****@gmail.com> wrote:
Also, is there any module that provides a generic DB API and can be
hooked to both Sybase and postgresql? This
(http://www.python.org/peps/pep-0249.html) looks pretty old.


Why would you need that? Python has a DB API, so all you have to do to
change from db to db is the connection string.

conn = Sybase.connection(.....)
conn = otherModules.connection(....)

Everthing else should work the same way.


....except that you may need to use different placeholders in SQL strings
for parameters to insert (sigh)...
Alex
Jul 18 '05 #11
al*****@yahoo.com (Alex Martelli) writes:
Josh Close <na****@gmail.com> wrote:
Also, is there any module that provides a generic DB API and can be
hooked to both Sybase and postgresql? This
(http://www.python.org/peps/pep-0249.html) looks pretty old.


Why would you need that? Python has a DB API, so all you have to do to
change from db to db is the connection string.

conn = Sybase.connection(.....)
conn = otherModules.connection(....)

Everthing else should work the same way.


...except that you may need to use different placeholders in SQL strings
for parameters to insert (sigh)...


....and there are of course variations in SQL from DBMS to DBMS...

IIRC, Steve Holden suggests in his book [1] the use of
internationalization (i18n) tools (eg. gettext) to make DB API code
portable. Seems unfortunately apt.
[1] "Python Web Programming", New Riders (2002)
John
Jul 18 '05 #12
[Alan Kennedy]
When looking at the DB-SIG web page, although I can see a list of
database modules there that support the DB-API in its different
versions and levels, I can see no easy way for that list to be
updated with the above sort of invaluable information.
Might it be a good idea to make at least part of the DB-SIG web
page a wiki/moin? A moin works well in the web
framework/templating arena, so perhaps it is also suitable for
database modules?


[Skip Montanaro] Go ahead and update the Python wiki:

http://www.python.org/moin

culling whatever dynamic information you think approrpriate from the
existing db-sig pages. Note that there are already several pages
with the word "database" in their titles. Search at the bottom of any
page to find them. It's likely one of them will be a better starting
place than a clean sheet of WikiPaper.

Once you have something, let me know and I'll update the
topics/data/modules page to refer to it. It would be extra helpful
if you could update a copy of this page:

http://www.python.org/topics/database/modules.ht

(note the lack of "ml" at the end) and shoot it to me. If so, that
will simplify my job.


Thanks for all your work on the python.org website Skip.

When I first posed my question, the sort of thing that I had in mind was
a comparison matrix, something like I've done for HTTP proxies:-

http://www.xhaus.com/alan/python/proxies.html

On browsing around the existing python moin, I see that exactly what I
suggested is already there, namely

http://www.python.org/moin/DbApiModuleComparison

and

http://www.python.org/moin/ChoosingDatabase

Although the DbApiModuleComparison seems less than 100% complete, I
think that may be because a lot of people don't know that it's there, so
they don't update it.

Maybe a good solution would be to simply link the above pages from the
DB-SIG main page, so that they can be more easily found?

I would make two small changes to the structure of the Module comparison
page:-

1. Change the "ThreadSupport" column to instead refer to the much more
tightly defined "threadsafety" variable from the DB-API spec, i.e.
"Integer constant stating the level of thread safety the interface
supports."

2. Add a "Pure python" column to differentiate between modules that are
pure python (and thus potentially portable between pythons), and modules
that require a native layer in C or Java, etc.

regards,

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Jul 18 '05 #13
On Sat, 25 Sep 2004 01:09:05 +0200, Alex Martelli <al*****@yahoo.com> wrote:
...except that you may need to use different placeholders in SQL strings
for parameters to insert (sigh)...


Forgot about that.... I use sybase for mssql connections, and freetds
doesn't have support for params, so I forgot about that.

-Josh
Jul 18 '05 #14
John J. Lee <jj*@pobox.com> wrote:
...
...except that you may need to use different placeholders in SQL strings
for parameters to insert (sigh)...
...and there are of course variations in SQL from DBMS to DBMS...


Yeah, _those_ I'm resigned to. No language can paper over them. But a
language shouldn't ADD difficulties such as placeholder differences.

IIRC, Steve Holden suggests in his book [1] the use of
internationalization (i18n) tools (eg. gettext) to make DB API code
portable. Seems unfortunately apt.

[1] "Python Web Programming", New Riders (2002)


Superb book, though unfortunately dated "pythonwise". I was a technical
reviewer for it and loved the experience -- and when I wanted to give
Anna, at the time my long-lost and recently-reconnected friend, a
birthday gift consonant to her nascent interest in Python, that's the
book I had Amazon deliver to her door. Since she's now my wife, and a
Python enthusiast, it seems to have worked. It's particularly great in
terms of the lightweight but useful coverage it gives on so many things,
from E/R design to HTTP and other protocols.

But on that one detail I beg to differ from my good friend Steve.
Dropping down to string-substitution is not really the best way to solve
SQL discrepancies among RDBMS's. Unfortunately, what I developed for
the purpose was a "work for hire", and to this day remains proprietary
to the firm I developed it for (think3 inc, if you must know) -- when I
resigned, one part of our verbal agreements was that they'd opensource
certain parts of their SW (mostly infrastructure aspects I had
developed) and I'd freely take them over and maintain them on
sourceforge or the like... they never followed through and I got tired
of pressuring them. Next time I should need that kind of thing from an
employer or client, I'm gonna get it in writing:-).

Anyway, the solution was born back in the day where we had to add
Informix to Ingres (or was it vice versa?) in the set of RDBMSs
supported by our ancillary applications (main applications were in the
CAD field for mechanical engineering, but RDBMS access was needed by
helper applications doing Bills of Materials and the like). Rather than
kludging it up as I was requested to do, I veered off on my own and made
up a more general solution -- part of my motivation was that I owned a
license of Watcom SQL and wanted to be able to develop at home using
that, even though supporting it was of no interest to the firm. To make
a long story short, it worked -- it basically reimplemented the original
Relational model, quite independent of SQL _as a language_, and
generated SQL on the fly (well, not quite on-the-fly, it was done
offline) in the required dialect. I remember later ports to such
'alien' RDBMSs as Oracle, Jet (aka [incorrectly] 'Access'), and SQL
Server, taking 1/4 the time management reasonably expected them to
(that's how I got to goof off on Usenet for 2/4ths of that time, and
still deliver in 3/4 of the time and look good;-).

But it's all captive, closed-source, proprietary stuff now. Sigh....
Alex
Jul 18 '05 #15
Josh Close <na****@gmail.com> wrote:
On Sat, 25 Sep 2004 01:09:05 +0200, Alex Martelli <al*****@yahoo.com> wrote:
...except that you may need to use different placeholders in SQL strings
for parameters to insert (sigh)...


Forgot about that.... I use sybase for mssql connections, and freetds
doesn't have support for params, so I forgot about that.


No support for parameters?! Talk about junk...!-(
Alex
Jul 18 '05 #16
On Sat, 25 Sep 2004 19:47:24 +0200, Alex Martelli <al*****@yahoo.com> wrote:
No support for parameters?! Talk about junk...!-(

Alex


Well put!

-Josh
Jul 18 '05 #17
Moof wrote:
Nelson Minar wrote:

While we're here, is there a free module for accessing SQLServer from
Python? Last I checked this Sybase driver was the only option.

Pywin32 (formerly win32all) has an odbc module which is DB-API 1.0 compliant.

I believe Mark Hammond doesn't make exaggerated claims for this module,
and I certainly wouldn't recommend it.
There's also adodbapi, which is DB-API 2.0 compliant.
For what it's worth, I actually managed to use adodbapi as a drop-in
replacement for mx.ODBC.Windows accessing a SQL Server database - there
were resource-utilization problems, which we eventually traced to IIS
(lest anyone should interpret this as criticism of mx.ODBC, an excellent
piece of software).
I haven't used the latter enough to work out if it's reasonably useful. I
don't get on with the former very well, though.

Oh, and non-free there's mxODBC, which also works under unix.
Also, remember, mx.ODBC's licensing allow use on non-commercial projects
without charge.
Also from unix someone mentioned a module based on ODBTP, which hasn't yet
surfaced out in the wild.

Moof


regards
Steve
Jul 18 '05 #18
Moof <us****@metamoof.net> wrote in message news:<2r*************@uni-berlin.de>...
While we're here, is there a free module for accessing SQLServer from
Python? Last I checked this Sybase driver was the only option.
Also from unix someone mentioned a module based on ODBTP, which hasn't yet
surfaced out in the wild.


Consider it surfaced.

It's still alpha, and I'm improving the packaging, but it's not hard
to install: http://benjiyork.com/odbtp.html.

I've been using it to access SQL Server, and other databases that
have Windows-only ODBC drivers from Linux. So far it works
wonderfully.
--
Benji York
http://benjiyork.com
Jul 18 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steve | last post by:
I am developing an application for a client that will have data in a MS SQL Server database. Costs have to be kept down so I have to develop using the free version of any and all tools I may need....
7
by: Steve Menard | last post by:
Here is my problem. I have this library thats hosts another language within python, and allows that language to call back INTO python. All is good as long as the other languages calls back on...
5
by: Widom | last post by:
Does anybody expirience Python for writing user front-end screens for SyBase-Anyware databse ? Where can I found more information how handle SyBase SQL-Anyware from Python ? Meybe it sounds...
0
by: Josh Close | last post by:
I'm getting these errors almost every time I use sybase. I'm using it with mssql. I build it like so: python setup.py build_ext -D WANT_THREADS -D HAVE_FREETDS -U WANT_BULKCOPY python setup.py...
3
by: John Fabiani | last post by:
Hi, I'm hoping someone on the list has connected to sybase/MsSQL with something that works with DBAPI 2.0 from a linux box (SUSE 9.2) because I can't seem to get it done. I found Object Craft's...
9
by: Norm Goertzen | last post by:
I've posted a previous question about IDEs and got some good feedback, thanks, but it does seem that everyone has their own favourite IDE -- in other words, no IDE was repeatedly recommended. ...
3
by: len | last post by:
Before posting I did search through the newsgroup and saw several references to people requesting the binaries to the Sybase module. However I did not see in these requests answers as to where they...
2
by: eight02645999 | last post by:
hi i am writing a CGI to process some database transactions using the Sybase module. so in my CGI script, i have: .... import Sybase import cgitb; cgitb.enable(display=1 ,...
113
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.