looking for ocbc example

Discussion in 'Python' started by Carl K, Sep 21, 2007.

  1. Carl K

    Carl K Guest

    I am sure this is what I want:
    http://www.python.org/topics/database/docs.html
    "The documentation for the PythonWin ODBC module."

    but it is 404.

    google isn't being nice.

    Anyone know where I can find some simple examples?

    I have used odbc in other environments, so just need to know what modules, and
    the lines to connect and execute a sql command.

    It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the difference?

    Carl K
     
    Carl K, Sep 21, 2007
    #1
    1. Advertising

  2. Carl K

    Tim Golden Guest

    Carl K wrote:
    > It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the difference?


    In short, pyodbc is open source; mxOdbc requires a commercial license.
    pyodbc is a newcomer, but appears to work for everything I've thrown
    at it (which is not much). mxOdbc has been around longer, and is sure
    to be a more mature product. It may offer more features & functionality.

    Unless you've got specific requirements (for example, commercial and/or
    bleeding-edge support) I suggest you start with pyodbc. You should be
    able to switch quite easily to mxODBC if that seems necessary later.

    TJG
     
    Tim Golden, Sep 21, 2007
    #2
    1. Advertising

  3. Carl K

    jay graves Guest

    On Sep 21, 2:43 am, Tim Golden <> wrote:
    > Carl K wrote:
    > > It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the difference?

    >
    > In short, pyodbc is open source; mxOdbc requires a commercial license.
    > pyodbc is a newcomer, but appears to work for everything I've thrown
    > at it (which is not much). mxOdbc has been around longer, and is sure
    > to be a more mature product. It may offer more features & functionality.


    There is also a brand new module 'ceODBC'.
    http://ceodbc.sourceforge.net/

    I haven't used it yet but I want to give it a try.

    ....
    Jay
     
    jay graves, Sep 21, 2007
    #3
  4. Carl K wrote:
    > I am sure this is what I want:
    > http://www.python.org/topics/database/docs.html
    > "The documentation for the PythonWin ODBC module."
    >
    > but it is 404.
    >
    > google isn't being nice.
    >
    > Anyone know where I can find some simple examples?
    >
    > I have used odbc in other environments, so just need to know what modules, and
    > the lines to connect and execute a sql command.


    Here's a very simple example for mxODBC:

    # mxODBC is available from http://www.egenix.com/products/python/mxODBC/:

    # On Windows:
    from mx.ODBC import Windows as Database

    # On Mac OS X:
    from mx.ODBC import iODBC as Database

    # On Linux/BSD/etc.:
    from mx.ODBC import unixODBC as Database
    # or
    from mx.ODBC import iODBC as Database

    # Open a connection to the database
    connection = Database.DriverConnect('DSN=<datasourcename>;'
    'UID=<username>;'
    'PWD=<password>;'
    'KEYWORD=<value>')
    # replace the values accordingly, add new keyword-value pairs as
    # necessary for your data source; data sources are configured
    # in the ODBC manager

    # Create a cursor; this is used to execute commands
    cursor = connection.cursor()

    # Create a table
    cursor.execute('CREATE TABLE mxodbcexample1 '
    ' (id integer, name varchar(10), data varchar(254))')
    # this command does not create a result set, so there's nothing
    # to fetch from the database; however in order to make the
    # change permanent, we need to commit the change
    connection.commit()

    # Prepare some data rows to add to the table, ie. a list of tuples
    rows = []
    for i in range(42):
    name = 'name-%i' % i
    data = 'value-%i' % i
    rows.append((i, name, data))

    # Add the data in one go; the values from the tuples get assigned
    # to the ?-mark parameter markers in the SQL statement based on
    # their position and the SQL statement is executed once for
    # each tuple in the list of rows
    cursor.executemany('INSERT INTO mxodbcexample1 VALUES (?,?,?)',
    rows)

    # If you apply changes to the database, be sure to commit or
    # rollback your changes; a call to .commit() or .rollback()
    # will implicitly start a new transaction
    connection.commit()

    # Now fetch some data rows
    from_id = 40
    to_id = 42
    cursor.execute('SELECT * FROM mxodbcexample1'
    ' WHERE (id >= ?) and (id < ?)',
    (from_id, to_id))

    # Fetch the results
    for i, row in enumerate(cursor.fetchall()):
    print 'Row %i: %r' % (i, row)

    # Remove the table again
    cursor.execute('DROP TABLE mxodbcexample1')
    connection.commit()

    # Close the connection
    connection.close()


    With MS Access this gives:

    Row 0: (40, 'name-40', 'value-40')
    Row 1: (41, 'name-41', 'value-41')

    --
    Marc-Andre Lemburg
    eGenix.com

    Professional Python Software directly from the Source
    >>> Python/Zope Consulting and Support ... http://www.egenix.com/
    >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
    >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/

    ________________________________________________________________________

    ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
     
    M.-A. Lemburg, Sep 21, 2007
    #4
  5. Carl K

    Carl K Guest

    jay graves wrote:
    > On Sep 21, 2:43 am, Tim Golden <> wrote:
    >> Carl K wrote:
    >>> It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the difference?

    >> In short, pyodbc is open source; mxOdbc requires a commercial license.
    >> pyodbc is a newcomer, but appears to work for everything I've thrown
    >> at it (which is not much). mxOdbc has been around longer, and is sure
    >> to be a more mature product. It may offer more features & functionality.

    >
    > There is also a brand new module 'ceODBC'.
    > http://ceodbc.sourceforge.net/
    >
    > I haven't used it yet but I want to give it a try.


    I tried it, and it worked better than pyodbc. (better is not exactly right.
    there was some weird bug in the ctree odbc driver, and the author of ceODBC gave
    me a workaround.)

    Carl K

    Carl K
     
    Carl K, Nov 28, 2007
    #5
  6. Carl K

    Tim Golden Guest

    Carl K wrote:
    > jay graves wrote:
    >> On Sep 21, 2:43 am, Tim Golden <> wrote:
    >>> Carl K wrote:
    >>>> It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the difference?
    >>> In short, pyodbc is open source; mxOdbc requires a commercial license.
    >>> pyodbc is a newcomer, but appears to work for everything I've thrown
    >>> at it (which is not much). mxOdbc has been around longer, and is sure
    >>> to be a more mature product. It may offer more features & functionality.

    >> There is also a brand new module 'ceODBC'.
    >> http://ceodbc.sourceforge.net/
    >>
    >> I haven't used it yet but I want to give it a try.

    >
    > I tried it, and it worked better than pyodbc. (better is not exactly right.
    > there was some weird bug in the ctree odbc driver, and the author of ceODBC gave
    > me a workaround.)


    All right, I'm a little perplexed as to whether "better" here
    refers to the admirable response of the ceOBDC author or to
    some other factors which demonstrate ceODBC's superiority.

    I've not really got the opportunity to pit them against each
    other so to speak, but I'd love to hear from someone who had.

    TJ
     
    Tim Golden, Nov 28, 2007
    #6
  7. Carl K

    supercooper Guest

    On Nov 28, 2:43 am, Tim Golden <> wrote:
    > Carl K wrote:
    > > jay graves wrote:
    > >> On Sep 21, 2:43 am, Tim Golden <> wrote:
    > >>> Carl K wrote:
    > >>>> It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the difference?
    > >>> In short, pyodbc is open source; mxOdbc requires a commercial license.
    > >>> pyodbc is a newcomer, but appears to work for everything I've thrown
    > >>> at it (which is not much). mxOdbc has been around longer, and is sure
    > >>> to be a more mature product. It may offer more features & functionality.
    > >> There is also a brand new module 'ceODBC'.
    > >>http://ceodbc.sourceforge.net/

    >
    > >> I haven't used it yet but I want to give it a try.

    >
    > > I tried it, and it worked better than pyodbc. (better is not exactly right.
    > > there was some weird bug in the ctree odbc driver, and the author of ceODBC gave
    > > me a workaround.)

    >
    > All right, I'm a little perplexed as to whether "better" here
    > refers to the admirable response of the ceOBDC author or to
    > some other factors which demonstrate ceODBC's superiority.
    >
    > I've not really got the opportunity to pit them against each
    > other so to speak, but I'd love to hear from someone who had.
    >
    > TJ


    Just tried ceODBC the other day (on XP), and it worked like a charm
    connecting SqlServer and DB2. Here's SqlServer:

    >>> import ceODBC
    >>> db=ceODBC.connect('DSN=Wells')
    >>> c=db.cursor()
    >>> c.execute('select wellname, latitudedecimal, longitudedecimal from dbo.wells where wellid in (11587,11194,11157)')
    >>> for each in c.fetchall():

    .... print each
    ....
    ('GILL #1-18', 33.095599, -92.38563)
    ('HOW #2-7', 35.10155, -91.48824)
    ('JKK #11-13', 34.09130, -93.45256)

    Simple! Very similar syntax to mxODBC.
     
    supercooper, Nov 29, 2007
    #7
  8. On Thu, 29 Nov 2007 08:24:52 -0800 (PST), supercooper
    <> declaimed the following in comp.lang.python:

    > >>> for each in c.fetchall():


    Most adapters work in iterator mode -- no need to use the
    ..fetchall(), just "for each in c"

    >
    > Simple! Very similar syntax to mxODBC.


    Similarly, most of the database adapters follow the DB-API spec --
    so follow the same set of calls; the only real differences are those
    involved with parameterized queries (is it ?, %s, etc.) and
    thread/module sharing level.
    --
    Wulfraed Dennis Lee Bieber KD6MOG

    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
     
    Dennis Lee Bieber, Nov 29, 2007
    #8
  9. Carl K

    luciyahelan

    Joined:
    Nov 26, 2010
    Messages:
    8
    Re: Starting a new Savings account

    I appreciate the concern which is been rose.
    ======================
     
    luciyahelan, Nov 26, 2010
    #9
  10. Carl K

    luciyahelan

    Joined:
    Nov 26, 2010
    Messages:
    8
    The things need to be sorted out because it is about the individual but it can be with everyone.
    ======================
     
    luciyahelan, Nov 26, 2010
    #10
  11. Carl K

    luciyahelan

    Joined:
    Nov 26, 2010
    Messages:
    8
    I like this particular article It gives me an additional input on the information around the world Thanks a lot and keep going with posting such information.
    ======================
     
    luciyahelan, Nov 26, 2010
    #11
  12. Carl K

    luciyahelan

    Joined:
    Nov 26, 2010
    Messages:
    8
    Well, it’s amazing. The miracle has been done. Well done.
    ======================
     
    luciyahelan, Nov 26, 2010
    #12
  13. Carl K

    luciyahelan

    Joined:
    Nov 26, 2010
    Messages:
    8
    Re: Starting a new Savings account

    A very smart and diplomatic answer. It’s really appreciable and general.
    ======================
     
    luciyahelan, Nov 26, 2010
    #13
  14. Carl K

    luciyahelan

    Joined:
    Nov 26, 2010
    Messages:
    8
    I subscribe to Insider Score, and that is correct there has been scant insider buying.
    ======================
     
    luciyahelan, Nov 26, 2010
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sugrue, Sean

    OCBC connection

    Sugrue, Sean, Sep 28, 2007, in forum: Python
    Replies:
    5
    Views:
    646
    Steve Holden
    Sep 28, 2007
  2. Sugrue, Sean

    FW: OCBC connection

    Sugrue, Sean, Sep 28, 2007, in forum: Python
    Replies:
    0
    Views:
    270
    Sugrue, Sean
    Sep 28, 2007
  3. Sugrue, Sean

    RE: OCBC connection

    Sugrue, Sean, Sep 28, 2007, in forum: Python
    Replies:
    0
    Views:
    418
    Sugrue, Sean
    Sep 28, 2007
  4. Sam Roberts
    Replies:
    15
    Views:
    302
    Sam Roberts
    Feb 7, 2005
  5. Regent

    Win32::OCBC problem

    Regent, Dec 31, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    120
    Matt Garrish
    Dec 31, 2003
Loading...

Share This Page