Help for DCOracle examples

Weiming He weiming at cnri.reston.va.us
Sat Jan 20 20:54:36 EST 2001


Oleg:

I am so pleased that you give me examples regarding DCOracle.
But I might missed something here. Look at my two sessions:
1.
    >>> import Buffer, oci_, sys
    >>> dbc=Connect("weiming/weiming")
    >>> c=dbc.cursor()
    Traceback (innermost last):
      File "<stdin>", line 1, in ?
    AttributeError: 'Connection' object has no attribute 'cursor'
    >>> c=dbc.Cursor()
    Traceback (innermost last):
      File "<stdin>", line 1, in ?
    AttributeError: 'Connection' object has no attribute 'Cursor'

    It complained AttributeError, regarding 'Connection' object has no attribute
'Cursor'

2.
    >>> import Buffer, oci_, sys
    >>> dbc=Connect("weiming/weiming")
    >>> c=oci_.newCursor(dbc)
    >>> c.execute("select * from emp")
    Traceback (innermost last):
      File "<stdin>", line 1, in ?
    AttributeError: execute

  It complained AttributeError too.

I saw your examples are prefect, but I am wondering why I have these AttributeError
above.
May I missed something? On your examples,  you have 'from DCOracle import Connect',
where is DCOracle? I only have oci_.so, Buffer.so, does them generate DCOracle? From
README.txt in release didn't say that.

I am sorry for having so many questions to ask you. But I am really appreciate you
would like
to give me some your good idea and advises. Thank you very much.

Weiming He

Oleg Broytmann wrote:

> On Fri, 19 Jan 2001, Weiming He wrote:
> > Thank you for your response. I got compile and link to Buffer.so and oci_.so.
> > Since it only has
> > one connection test python program with the release, can you point me where can
> > I find examples including
> > query, insert, update and etc. Or if you have some, would you please show me
> > one or two.
> > Thank you very much.
>
>    (JWT = jwt.com = J. Walter Thompson; once I wrote a site for their
> Russian branch jwt.ru; the site was not deployed)
>
> ----- file jwt_connecnt.py -----
> jwt = None
>
> import os
> os.environ["ORACLE_HOME"] = "/usr/local/oracle/app/oracle/product/8.0.5"
> os.environ["NLS_LANG"] = "AMERICAN_AMERICA.CL8KOI8R"
>
> def jwt_connect(login="xxx", password="yyy", SID="jwt_cm"):
>    global jwt
>    from DCOracle import Connect
>    jwt = Connect("%s/%s@%s" % (login, password, SID))
> ----- /file jwt_connecnt.py -----
>
> ----- file test1.py -----
> #! /usr/local/bin/python -O
> "Simple test"
>
> from jwt_connect import jwt_connect
> jwt_connect()
> from jwt_connect import jwt
>
> cursor = jwt.cursor()
> format = "%s | "*13 + "%s\n"
>
> cursor.execute("SELECT * FROM sides_view")
> while 1:
>    olist = cursor.fetchmany(10)
>    if not olist: break
>    for row in olist:
>       sys.stdout.write(format % row)
>
> cursor.close()
> jwt.close()
> ----- /file test1.py -----
>
> ----- file test2.py -----
> #! /usr/local/bin/python -O
> "LOB (large objects) and procedures example"
>
> from jwt_connect import jwt_connect
> jwt_connect()
> from jwt_connect import jwt
>
> #infile = open("xxx", 'r')
> #data = infile.read()
> #infile.close()
>
> print "Creating..."
> id = jwt.procedures.add_side_image(1028, 1423)
> print "New id =", id
>
> print "Loading image..."
> try:
>    jwt.execute("""SELECT the_image FROM images
>      WHERE id_image = %d
>        FOR UPDATE OF the_image""" % id)
>
>    lob = jwt.fetchone()[0]
>    lob.write("xyzzy")
>
> finally:
>    jwt.close()
> ----- /file test2.py -----
>
> Oleg.
> ----
>      Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
>            Programmers don't die, they just GOSUB without RETURN.




More information about the Python-list mailing list