On Fri, Feb 08, 2008 at 03:07:33PM -0600, Mike Driscoll wrote:
> I am a newb when it comes to SQLObject.

   Welcome!

> from sqlobject import *
> 
> # mssql://user:[EMAIL PROTECTED]:port/db
> connection =
> connectionForURI('mssql://user:[EMAIL PROTECTED]:port/db')
> sqlhub.processConnection = connection
> 
> class tblAcctPrefs(SQLObject):    
>     # these are the actual column names
>     # is that a no-no?
>     empID = StringCol()
>     pref_name = StringCol()
>     pref_value = StringCol()
> 
> tblAcctPrefs._connection.debug = True

   This could be achieved by
connectionForURI('mssql://user:[EMAIL PROTECTED]:port/db?debug=1')

> prefs = tblAcctPrefs.select()
> list(prefs)
> 
> 1) Why does it change my column name from empID to emp_id?

   This how "styles" in SQLObject works. Default style changes uppercase to
lowercase and adds underscores.

> 2) Why does it insist on querying against an id column that I do not
> specify?

   Every SQLObject's table must have a Primary Key id (not necessary named
"id").

> 3) How do I do this correctly?

   ALTER TABLE to add the id column. Or, if empID is the Primary Key, use
it as the id:

class tblAcctPrefs(SQLObject):
    class sqlmeta:
        idName = "emp_id"
        idType = str
    pref_name = StringCol()
    pref_value = StringCol()

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to