On Tue, Sep 29, 2009 at 09:03:51AM +0100, Chris Wood wrote: > I'm new to using SQLObject,
Welcome! > and having some problems with getting it > to recognise my current MySQL database. Making SQLObject to work with existing databases could be problematic, sometimes even impossible; let's hope it's not your case. > class Table1(sqlobject.SQLObject): > _connection = conn > _fromDatabase = True > > class sqlmeta: > table = 'Table1' > idName = 'Table1ID' > > BOB = StringCol() You don't need both _fromDatabase and columns. Either you use _fromDatabase and allow SQLObject to get the list of columns from the backend, or you declare your columns yourself. > I've seen the attribute in class sqlmeta of 'columns' - will this find > my column names automatically, Yes, if _fromDatabase = True. > or do I still need to input them > manually? If the latter..: Yes, if _fromDatabase = False. > I assume I set the names of each column in the instance of sqlmeta > (like I have done with the table name) - how do I do this?! Do I do > this before or after I've told SQLObject that the BOB column is a > String column? SQLObject processes your class declaration as a whole so it doesn't matter (if I understand your question correctly). class Table1(sqlobject.SQLObject): _connection = conn class sqlmeta: table = 'Table1' idName = 'Table1ID' BOB = StringCol() is the same as class Table1(sqlobject.SQLObject): class sqlmeta: table = 'Table1' idName = 'Table1ID' _connection = conn BOB = StringCol() is the same as class Table1(sqlobject.SQLObject): _connection = conn BOB = StringCol() class sqlmeta: table = 'Table1' idName = 'Table1ID' (See - I didn't use _fromDatabase and SQLObject assumes it's False and expects you to provide a list of columns) > Is there a published list of the default naming convention that > SQLObject follows? I couldn't find it on the website. SQLObject uses "style" to convert names between Python and backend. See styles.py for existing styles. Default style is MixedCaseUnderscoreStyle but you can change it for a class (table), a group of classes or the entire program. If you don't want to override the entire style but only want to change a few names (of if your existing DB doesn't follow any style at all) - you can set the names for the table and the columns: class Table1(sqlobject.SQLObject): class sqlmeta: table = 'Table1' idName = 'Table1ID' _connection = conn BOB = StringCol(dbName='strbob') Oleg. -- Oleg Broytman http://phd.pp.ru/ p...@phd.pp.ru Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss