Hi,

I am a newb when it comes to SQLObject. I have been working through
TurboGears tutorials and books and decided to try to make my own app.
Unfortunately, I seem to be doing something wrong. All I'm doing is trying
to do a "select *". Here's what I've got so far:

<code>

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
prefs = tblAcctPrefs.select()
list(prefs)

</code>

This gives me a goofy traceback like this:

DatabaseError: internal error: SQL Server message 207, severity 16, state
3, line 1:
Invalid column name 'id'.
SQL Server message 207, severity 16, state 3, line 1:
Invalid column name 'emp_id'.
DB-Lib error message 10007, severity 5:
General SQL Server error: Check messages from the SQL Server.

The debug spits this out:

1/Select  :  SELECT tbl_acct_prefs.id, tbl_acct_prefs.emp_id,
tbl_acct_prefs.pref_name, tbl_acct_prefs.pref_value FROM tbl_acct_prefs
WHERE 1 = 1
1/QueryR  :  SELECT tbl_acct_prefs.id, tbl_acct_prefs.emp_id,
tbl_acct_prefs.pref_name, tbl_acct_prefs.pref_value FROM tbl_acct_prefs
WHERE 1 = 1

I changed the class to this:

<code>

class tblAcctPrefs(SQLObject):    
    class sqlmeta:
        fromDatabase = True

</code>

and now I get just one invalid table error:

DatabaseError: internal error: SQL Server message 207, severity 16, state
3, line 1:
Invalid column name 'id'.
DB-Lib error message 10007, severity 5:
General SQL Server error: Check messages from the SQL Server.


My questions are:

1) Why does it change my column name from empID to emp_id?
2) Why does it insist on querying against an id column that I do not
specify?
3) How do I do this correctly?

I'm sure I'll be asking other simple questions as well. I'm currently
using the latest SQLObject (I think) with Python 2.4 on Windows XP. Thanks
a lot! 

Mike Driscoll
Applications Specialist
MCIS - Technology Center


-------------------------------------------------------------------------
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