forceDBName=False

Hi, trying to connect to the existing Firebird database from the Windows XP machine, I am getting following strange Error:

import *
from sqlobject.sqlbuilder import *

db_filename = 'd|/sgdata/test/sysdat01.gdb'
connection_string = 'firebird://172.18.0.10:3050/' + db_filename
connection = connectionForURI(connection_string)

class Cenktgm01(SQLObject):
   _connection = connection   
   class sqlmeta:       
       fromDatabase = True

Cenktgm01._connection.debug = True
myTry = Cenktgm01()



Microsoft Windows XP [Verze 5.1.2600]
C:\automat>python pokusy.py
Traceback (most recent call last):
  File "pokusy.py", line 54, in <module>
    class Cenktgm01(SQLObject):
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\declarative.py", line 112, in __new__
    cls.__classinit__(cls, new_attrs)
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py", line 781, in __classinit__
    cls.sqlmeta.addColumnsFromDatabase()
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py", line 443, in addColumnsFromDatabase
    sqlmeta.addColumn(columnDef)
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py", line 369, in addColumn
    setter = eval('lambda self, val: self._SO_setValue(%s, val, self.%s, self.%s)' % (repr(name), '_SO_from_python_%s' % name, '_SO_to_python_%s'
% name))
  File "<string>", line 1
    lambda self, val: self._SO_setValue('p$defkod', val, self._SO_from_python_p$defkod, self._SO_to_python_p$defkod)
                                                                               ^
SyntaxError: invalid syntax


Thanks for your comments

Petr


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Simon Cross | 7 May 13:55

Re: forceDBName=False

On Wed, May 7, 2008 at 12:15 PM, Petr Jakeš <petr.jakes <at> tpc.cz> wrote:
> Hi, trying to connect to the existing Firebird database from the Windows XP
> machine, I am getting following strange Error:

> "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py",
> line 369, in addColumn
>     setter = eval('lambda self, val: self._SO_setValue(%s, val, self.%s,
> self.%s)' % (repr(name), '_SO_from_python_%s' % name, '_SO_to_python_%s'
>  % name))
>   File "<string>", line 1
>     lambda self, val: self._SO_setValue('p$defkod', val,
> self._SO_from_python_p$defkod, self._SO_to_python_p$defkod)

It looks like a really strange column name (p$defkod) has somehow been
introspected from the Firebird database. Do you have any columns with
names similar to that?

Schiavo
Simon
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Re: forceDBName=False



On Wed, May 7, 2008 at 1:55 PM, Simon Cross <hodgestar <at> gmail.com> wrote:
On Wed, May 7, 2008 at 12:15 PM, Petr Jakeš <petr.jakes <at> tpc.cz> wrote:
> Hi, trying to connect to the existing Firebird database from the Windows XP
> machine, I am getting following strange Error:

> "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py",
> line 369, in addColumn
>     setter = eval('lambda self, val: self._SO_setValue(%s, val, self.%s,
> self.%s)' % (repr(name), '_SO_from_python_%s' % name, '_SO_to_python_%s'
>  % name))
>   File "<string>", line 1
>     lambda self, val: self._SO_setValue('p$defkod', val,
> self._SO_from_python_p$defkod, self._SO_to_python_p$defkod)

It looks like a really strange column name (p$defkod) has somehow been
introspected from the Firebird database. Do you have any columns with
names similar to that?

Yes, there are column names like OID$CENKTGM01, MJ$TYP, AU$VYNOSY, AU$VYNOSY, AU$ZASOBY etc. in the table.
The designer of the database is saying such a names are alowed according to the ANSI-92 SQL.

Petr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 8 May 11:04
X-Face

Re: forceDBName=False

On Thu, May 08, 2008 at 10:55:14AM +0200, Petr Jake?? wrote:
> Yes, there are column names like OID$CENKTGM01, MJ$TYP, AU$VYNOSY,
> AU$VYNOSY, AU$ZASOBY etc. in the table.
> The designer of the database is saying such a names are alowed according to
> the ANSI-92 SQL.

   SQLObject currently allows only columns that are proper Python identifiers.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Oleg Broytmann | 8 May 11:06
X-Face

Re: forceDBName=False

On Thu, May 08, 2008 at 01:04:32PM +0400, Oleg Broytmann wrote:
> On Thu, May 08, 2008 at 10:55:14AM +0200, Petr Jake?? wrote:
> > Yes, there are column names like OID$CENKTGM01, MJ$TYP, AU$VYNOSY,
> > AU$VYNOSY, AU$ZASOBY etc. in the table.
> > The designer of the database is saying such a names are alowed according to
> > the ANSI-92 SQL.
> 
>    SQLObject currently allows only columns that are proper Python identifiers.

   The workaround is like this:

class MyTable(SQLObject):
   column = StringCol(dbName="a$column")

though I am not sure it would help in all cases.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Re: forceDBName=False

> > Yes, there are column names like OID$CENKTGM01, MJ$TYP, AU$VYNOSY,
> > AU$VYNOSY, AU$ZASOBY etc. in the table.
> > The designer of the database is saying such a names are alowed according to
> > the ANSI-92 SQL.
>
>    SQLObject currently allows only columns that are proper Python identifiers.

  The workaround is like this:

class MyTable(SQLObject):
  column = StringCol(dbName="a$column")

though I am not sure it would help in all cases.

Thanks Oleg, I was reading about this feature of SQLObject. But my feeling was it is necessary to
type all column names manually if the
class sqlmeta:       
       fromDatabase = True
is not used.
To be more specific, I mean it is necessary to type in all column names used in the tabel, not just some of them.

Petr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 8 May 11:27
X-Face

Re: forceDBName=False

On Thu, May 08, 2008 at 11:17:30AM +0200, Petr Jake?? wrote:
> Thanks Oleg, I was reading about this feature of SQLObject. But my feeling
> was it is necessary to
> type all column names manually if the
> class sqlmeta:
>        fromDatabase = True
> is not used.
> To be more specific, I mean it is necessary to type in all column names used
> in the tabel, not just some of them.

   You can use both at the same time:

class MyTable(SQLObject):
   clas sqlmeta:
      fromDatabase=True
   name = StringCol(dbName="a$col")

   I.e. draw the columns' descriptions from the database but override some
of them.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Re: forceDBName=False


  You can use both at the same time:

class MyTable(SQLObject):
  clas sqlmeta:
     fromDatabase=True
  name = StringCol(dbName="a$col")

  I.e. draw the columns' descriptions from the database but override some
of them.

I was trying above mentioned....
on the Win machine still the same error message:
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py", line 369, in addColumn
    setter = eval('lambda self, val: self._SO_setValue(%s, val, self.%s, self.%s)' % (repr(name), '_SO_from_python_%s' % name, % name))
  File "<string>", line 1
    lambda self, val: self._SO_setValue('p$defkod', val, self._SO_from_python_p$defkod, self._SO_to_python_p$defkod)
                                                                               ^
SyntaxError: invalid syntax

on the Linux machine not a syntax error but:
kinterbasdb.OperationalError: (-902, 'isc_attach_database: \n  Unable to complete network request to host "172.18.0.10".\n  Failed to establish a connection.\n  Connection timed out ')


Trying to connect to the database using kinterdb works:

import kinterbasdb; kinterbasdb.init(type_conv=200),  kinterbasdb.typeconv_text_unicode
con = kinterbasdb.connect(dsn='172.18.0.10:d:\\sgdata\\test\\sysdat01.gdb', user=uzivatel,
                password=heslo, charset='UNICODE_FSS')
cur = con.cursor()

Petr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 8 May 13:24
X-Face

Re: forceDBName=False

On Thu, May 08, 2008 at 12:56:09PM +0200, Petr Jake?? wrote:
> on the Win machine still the same error message:
>   File
> "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py",
> line 369, in addColumn
>     setter = eval('lambda self, val: self._SO_setValue(%s, val, self.%s,
> self.%s)' % (repr(name), '_SO_from_python_%s' % name, % name))
>   File "<string>", line 1
>     lambda self, val: self._SO_setValue('p$defkod', val,
> self._SO_from_python_p$defkod, self._SO_to_python_p$defkod)
> 
> ^
> SyntaxError: invalid syntax

   Then, it seems, there is no way to make this work with fromDatabase.
BTW, SQL-92 doesn't allow '$' in identifiers - it only allows letters,
digits and underscore (though most databases extend the rule and allow '$'
anyway).

> on the Linux machine not a syntax error but:
> kinterbasdb.OperationalError: (-902, 'isc_attach_database: \n  Unable to
> complete network request to host "172.18.0.10".\n  Failed to establish a
> connection.\n  Connection timed out')

   Certainly not a related problem.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Re: forceDBName=False


  Then, it seems, there is no way to make this work with fromDatabase.
BTW, SQL-92 doesn't allow '$' in identifiers - it only allows letters,
digits and underscore (though most databases extend the rule and allow '$'
anyway).
 
 :-(

The table I would like to connect to has about 130 columns. I would like to read/write data from/to some columns only. Is there a way not to name all 130 columns in the table definition (in the class definition)? I mean is there a way to specify only columns I want to read/write from/to?


Petr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 8 May 14:15
X-Face

Re: forceDBName=False

On Thu, May 08, 2008 at 02:05:20PM +0200, Petr Jake?? wrote:
> The table I would like to connect to has about 130 columns. I would like to
> read/write data from/to some columns only. Is there a way not to name all
> 130 columns in the table definition (in the class definition)? I mean is
> there a way to specify only columns I want to read/write from/to?

   Just declare columns you need and don't use fromDatabase:

class MyTable(SQLObject):
   name = StringCol(dbName="a$name")
   value = IntCol(dbName="the$value")

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Re: forceDBName=False

  Just declare columns you need and don't use fromDatabase:

class MyTable(SQLObject):
  name = StringCol(dbName="a$name")
  value = IntCol(dbName="the$value")


Yes, I remember I was trying such a syntax at the begening but SQLObject was complaining about ID generator and I was not able to solve it.

kinterbasdb.ProgrammingError: (-104, 'isc_dsql_prepare: \n  invalid request BLR at offset 73\n  generator GEN_CENKTGM01 is not defined')


(really trying to search the doc etc. and googling a lot before this posting/reply... sorry).

Petr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 8 May 15:22
X-Face

Re: forceDBName=False

On Thu, May 08, 2008 at 03:02:17PM +0200, Petr Jake?? wrote:
> kinterbasdb.ProgrammingError: (-104, 'isc_dsql_prepare: \n  invalid request
> BLR at offset 73\n  generator GEN_CENKTGM01 is not defined')

   No idea what it is. At what time and place SQLObject raises this?

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Re: forceDBName=False

  No idea what it is. At what time and place SQLObject raises this?
 
The code looks like:
class Cenktgm01(SQLObject):
    _connection = connection
    nazev = StringCol(dbName="nazev")

myTable = Cenktgm01()

and the traceback is:

C:\automat>python pokusy.py
Traceback (most recent call last):
  File "pokusy.py", line 60, in <module>
    myTry = Cenktgm01()
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\declarative.py", line 89, in _wrapper
    return fn(self, *args, **kwargs)
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py", line 1181, in __init__
    self._create(id, **kw)
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py", line 1212, in _create
    self._SO_finishCreate(id)
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\main.py", line 1236, in _SO_finishCreate
    id, names, values)
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\dbconnection.py", line 391, in queryInsertID
    return self._runWithConnection(self._queryInsertID, soInstance, id, names, values)
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\firebird\firebirdconnection.py", line 59, in _runWithConnection
    val = meth(conn, *args)
  File "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\firebird\firebirdconnection.py", line 98, in _queryInsertID
    % sequenceName)
kinterbasdb.ProgrammingError: (-104, 'isc_dsql_prepare: \n  invalid request BLR at offset 73\n  generator GEN_CENKTGM01 is not defined')


Petr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 8 May 15:38
X-Face

Re: forceDBName=False

On Thu, May 08, 2008 at 03:33:51PM +0200, Petr Jake?? wrote:
>   File
> "C:\Python25\lib\site-packages\sqlobject-0.10dev_r3187-py2.5.egg\sqlobject\firebird\firebirdconnection.py",
> line 98, in _queryInsertID
>     % sequenceName)
> kinterbasdb.ProgrammingError: (-104, 'isc_dsql_prepare: \n  invalid request
> BLR at offset 73\n  generator GEN_CENKTGM01 is not defined')

Line 98, in _queryInsertID: it tried to execute

            c.execute('SELECT gen_id(%s,1) FROM rdb$database'
                                % sequenceName)

   where

        sequenceName = soInstance.sqlmeta.idSequence or \
                               'GEN_%s' % table

   What is the actual sequence name for the table?

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Re: forceDBName=False

Line 98, in _queryInsertID: it tried to execute

           c.execute('SELECT gen_id(%s,1) FROM rdb$database'
                               % sequenceName)

  where

       sequenceName = soInstance.sqlmeta.idSequence or \
                              'GEN_%s' % table

  What is the actual sequence name for the table?
 
There is not a sequence generator for this table in the database. All records IDs are generated by the application code.

Petr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytmann | 8 May 16:06
X-Face

Re: forceDBName=False

On Thu, May 08, 2008 at 04:02:45PM +0200, Petr Jake?? wrote:
> There is not a sequence generator for this table in the database. All
> records IDs are generated by the application code.

   Then you have to generate an ID and pass it to SQLObject:

myTable = Cenktgm01(id=ID)

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Re: forceDBName=False

  Then you have to generate an ID and pass it to SQLObject:

myTable = Cenktgm01(id=ID)


Yeah, this works, thanks....
Petr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Gmane