Oleg Broytmann | 5 Aug 2009 18:37
X-Face
Picon
Favicon

SQLObject 0.11.0b1

Hello!

I'm pleased to announce version 0.11.0b1, the first beta release of 0.11 branch
of SQLObject.

What is SQLObject
=================

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).

Where is SQLObject
==================

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

(Continue reading)

Daniel Fetchinson | 11 Aug 2009 04:09

Re: SQLObject 0.11.0b1

> I'm pleased to announce version 0.11.0b1, the first beta release of 0.11
> branch
> of SQLObject.

Thanks Oleg!

My application runs without issue using the new version.

Cheers,
Daniel

--

-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
Tom Coetser | 11 Aug 2009 07:40

Re: RealatedJoin (was: ManyToMany)

Hi Oleg,

I got sidetracked on something else and am only now able to get back to this. 
Thank you for your reply.

On Friday 31 July 2009 12:29:55 Oleg Broytmann wrote:
> On Fri, Jul 31, 2009 at 09:36:19AM +0200, Tom Coetser wrote:
> > I am trying to get my head around using a ManyToMany relation between
[snip]
>    The worst problem with ManyToMany is not documentation. The code was
> added by the original author before he left the project, and I don't know
> if the code by any means complete. I never used it. Consider it an
> unfinished experimental code. Use RelatedJoin or SQLRelatedJoin instead.

Noted, thank you.

[snip]

I am now using this option but have a question w.r.t. destroySelf(). Given the 
following:

-------- cut ---------------------
class Member(SQLObject):
    name = StringCol(alternateID=True)
    roles = SQLRelatedJoin('Role', intermediateTable='member_role',
                               createRelatedTable=False)

class Role(SQLObject):
    name = StringCol(alternateID=True)
    members = SQLRelatedJoin('Member', intermediateTable='member_role',
(Continue reading)

Ray Van Dolson | 11 Aug 2009 22:12
Favicon

Getting odd syntax error...

Using sqlobject 0.9.9 with pymssql 1.0.1 on RHEL 5.3 (the
aforementioned have been installed with yum via either the base OS
packaeges or EPEL).

I have a class defined similar to the following:

class SystemsInfo(SQLObject):
  class sqlmeta:
    style = MixedCaseStyle(longID=True)
    fromDatabase = False
    table = 'SystemsInfo'
    idType = str
    idName = 'SystemName'
    lazyUpdate = True

  Department = StringCol(length=30, default=None)
  Vendor = StringCol(length=80, default=None)
  Model = StringCol(length=80, default=None)
  ... (lots more columns)

And eventually a very simple query as follows:

  a = SystemsInfo.select(SystemsInfo.q.id == "SYSNAME")
  item = a.getOne()

Debug output shows the following:

 1/Select  :  SELECT SystemsInfo.SystemName, SystemsInfo.Department,
  SystemsInfo.Vendor, SystemsInfo.Model FROM SystemsInfo WHERE
  ((SystemsInfo.SystemName) = ('SYSNAME'))
(Continue reading)

Ray Van Dolson | 11 Aug 2009 23:07
Favicon

Re: Getting odd syntax error...

On Tue, Aug 11, 2009 at 01:12:08PM -0700, Ray Van Dolson wrote:
> Using sqlobject 0.9.9 with pymssql 1.0.1 on RHEL 5.3 (the
> aforementioned have been installed with yum via either the base OS
> packaeges or EPEL).

Egg on my face.  This appears to be a known issue with pymssql 1.0.1.
Upgrading to 1.0.2 fixed the problem:

  - fixed severe bug introduced in 1.0.0 that caused some queries to be
    truncated or overwritten with binary garbage - many thanks to Igor
    Nazarenko who found the exact cause of the bug,

Sorry for the noise all.

Ray

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
Ray Van Dolson | 12 Aug 2009 01:53
Favicon

Allowing DateTime to be specified as a string...

Hi all;

It seems like this worked in the past, but I could just be imagining
things :)

I have a column in my database defined as a DateTimeCol with no default
and where NULL is allowed.  I'm parsing a CSV file and one of the
columns in the CSV file corresponds with this DateTimeCol.

The CSV value is a string of time.struct_time (ie parseable by
strptime()).

When I update a row or create a new entry passing this string as the
value for the column, the validator returns an error because it's not a
datetime object.

I scratch my head here because I'm *sure* I have used my script in the
past with similar date strings and sqlobject has transparently inserted
them into my database without problem...

In any case, in the here and now I'm trying to figure out the best way
to handle this.

I could write a simple function to check whether or not I'm on a column
in my CSV file that has a date/time value, generate a datetime object
from it and pass it along as the value for updating.  The downside here
is that I then need to know ahead of time which columns will have date
values in them and I'd like to not have to manually track and code for
such scenarios if possible.

(Continue reading)

Oleg Broytmann | 12 Aug 2009 09:43
X-Face
Picon
Favicon

Re: SQLObject 0.11.0b1

On Mon, Aug 10, 2009 at 07:09:39PM -0700, Daniel Fetchinson wrote:
> > I'm pleased to announce version 0.11.0b1, the first beta release of 0.11
> > branch
> > of SQLObject.
> 
> Thanks Oleg!
> 
> My application runs without issue using the new version.

   Thank you for the report!

Oleg.
--

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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
Oleg Broytmann | 12 Aug 2009 09:44
X-Face
Picon
Favicon

Re: Getting odd syntax error...

On Tue, Aug 11, 2009 at 02:07:17PM -0700, Ray Van Dolson wrote:
> On Tue, Aug 11, 2009 at 01:12:08PM -0700, Ray Van Dolson wrote:
> > Using sqlobject 0.9.9 with pymssql 1.0.1 on RHEL 5.3 (the
> > aforementioned have been installed with yum via either the base OS
> > packaeges or EPEL).
> 
> Egg on my face.  This appears to be a known issue with pymssql 1.0.1.
> Upgrading to 1.0.2 fixed the problem:
> 
>   - fixed severe bug introduced in 1.0.0 that caused some queries to be
>     truncated or overwritten with binary garbage - many thanks to Igor
>     Nazarenko who found the exact cause of the bug,

   Good!

> Sorry for the noise all.

   Ok.

Oleg.
--

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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
(Continue reading)

Oleg Broytmann | 12 Aug 2009 09:51
X-Face
Picon
Favicon

Re: Allowing DateTime to be specified as a string...

On Tue, Aug 11, 2009 at 04:53:12PM -0700, Ray Van Dolson wrote:
> It seems like this worked in the past, but I could just be imagining
> things :)

   Yes, long ago all column types accepted strings and passed them to the
backend as is. Later it was decided to make conversion stricter.

> I could write a simple function to check whether or not I'm on a column
> in my CSV file that has a date/time value, generate a datetime object
> from it and pass it along as the value for updating.

   I'd very much recommend that way. With this you can check that the
values are really date/time values in your preferred format.

> The other option (and what I ended up doing for now) is to modify the
> DateTimeValidator

   You don't need to modify the builtin validator. You can create your own
column type (inherited from DateTimeCol) with your own validator (inherited
from DateTimeValidator). Or you can pass a validator to the column, and
your validator will be stacked on top of the DateTimeValidator. See
examples at
http://svn.colorstudy.com/SQLObject/trunk/sqlobject/tests/test_validation.py

Oleg.
--

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

------------------------------------------------------------------------------
(Continue reading)

Oleg Broytmann | 12 Aug 2009 10:06
X-Face
Picon
Favicon

Re: RealatedJoin

On Tue, Aug 11, 2009 at 07:40:12AM +0200, Tom Coetser wrote:
> class Member(SQLObject):
>     name = StringCol(alternateID=True)
>     roles = SQLRelatedJoin('Role', intermediateTable='member_role',
>                                createRelatedTable=False)
> 
> class Role(SQLObject):
>     name = StringCol(alternateID=True)
>     members = SQLRelatedJoin('Member', intermediateTable='member_role',
>                                createRelatedTable=False)
> 
> class MemberRole(SQLObject):
>     member = ForeignKey('Member', notNull=True, cascade=False)
>     role = ForeignKey('Role', notNull=True, cascade=False)
> 
> When I call destroySelf() on a member though, I would like to **not** have 
> that member deleted if it still has any roles assigned to it. I tried setting 
> the cascade=False option in the intermediate table, but this does not help 
> because it looks like the base destroySelf() method automatically deletes any 
> RelatedJoins.

   First thing I can guess your are using a backend that doesn't support
CASCADE (SQLite?) With SQLite, you can CREATE a TRIGGER to prevent deletion
from the intermediate table, but you have to do it yourself.
   .destroySelf() actually doesn't rely on the backend support for CASCADE;
instead it uses it itself, but not on the RelatedJoin's intermediate table
even if the table is declared explicitly. The simplest way I see is to
override .destroySelf:

class Member(SQLObject):
(Continue reading)


Gmane