Michael Simons wrote:
Does anyone work w/ PyDO on SAP DB or has worked with it?

I'm trying hard to get it run but it seems like the sapdb interface for PyDO doesn't work correctly.

If you could be a more specific about the kinds of errors/problems.


I got the following script running, but I had to make two changes to PyDO/sapdbconn.py:
- initialize the variable host in _parseConnectString
- change the string in sqlStringAndValue from SYSDATE to TIMESTAMP


Perhaps you should try to connect to SAP DB outside of PyDO to make sure that everything's OK with Python versions and PYTHONPATH.

# sapdbdemo.py
import sapdb.dbapi as dbapi

database = 'TST'
username = 'TEST'
password = 'TEST'

#
# create schema
#

session = dbapi.connect (username, password, database)

def createObject (session, kind, name, definition = ''):
    cursor = session.cursor ()
    try:
        cursor.execute ('drop %s %s' % (kind, name))
    except:
        pass
    cursor.execute ('create %s %s %s' % (kind, name, definition))

createObject (session, 'table', 'users', """(
    OID FIXED (38),
    USERNAME VARCHAR(16),
    PASSWORD VARCHAR(16),
    CREATED TIMESTAMP,
    LAST_MOD TIMESTAMP
)""")

createObject (session, 'sequence', 'USERS_OID_SEQ')

session.commit ()

#
# actual PyDo code
#

from PyDO import *
DBIInitAlias('TEST', 'pydo:sapdb:[EMAIL PROTECTED] TEST TEST')
class Users(PyDO):
    connectionAlias = 'TEST'
    table = 'USERS'
    fields = (
        ('OID'     , 'NUMBER'),
        ('USERNAME', 'VARCHAR(16)'),
        ('PASSWORD', 'VARCHAR(16)'),
        ('CREATED' , 'DATE'),
        ('LAST_MOD', 'DATE')
        )
    sequenced = {
        'OID': 'USERS_OID_SEQ'
        }
    unique = [ 'OID', 'USERNAME' ]

newUser = Users.new(USERNAME = 'drew', PASSWORD = 'foo', CREATED = SYSDATE,
                    LAST_MOD = SYSDATE)

print newUser.items ()
# end script

Daniel Dittmar

--
Daniel Dittmar
SAP DB, SAP Labs Berlin
[EMAIL PROTECTED]
http://www.sapdb.org


_______________________________________________ sapdb.general mailing list [EMAIL PROTECTED] http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to