From: marcelo s. <mar...@gm...> - 2006-10-27 12:43:26
|
I before could not solve this problem. Directly I was defining: class centro(SQLObject): _connection=connection descripCentro=StringCol() practicas = RelatedJoin('practica') class practica(SQLObject): _connection=connection descripPractica=StringCol() valorTotalPractica=FloatCol() centros = RelatedJoin('centro') centro.createTable () practica.createTable () The previous definition implies that SQLObject generates a table centro_practica Before I could not add another FIELD to the table centro_practica. Thank you Regards On 10/26/06, Rick Flosi <rf...@im...> wrote: > Ah, I should have mentioned that I use Postgres 7.x with this. > I haven't used MySQL with this before. > Were you able to resolve this? What was different? > > -- > Rick > > On Thu, 26 Oct 2006, marcelo schiavone wrote: > > > Hola Rick > > I did what you said to me. > > Thank you all good worked. > > > > I worked with PostgreSQL 8.0.3 and MySQL 5.0. > > In PostgreSQL it worked correctly. > > In MySQL on having entered: > > > > " PracticaCentro.createTable () " > > > > It showed the following error: > > > > " ProgrammingError: (1064, " You have an mistake in your SQL syntax; > > check the manual that corresponds to your MySQL server version for the > > right syntax to uses near ' unique (practica_id, centro_id) ' at line > > 1 ") " > > > > But equal it created the table "centro_practica" > > > > > > Thank you > > Regards > > > > On 10/26/06, Rick Flosi <rf...@im...> wrote: > >> Marcelo, > >> > >> This should work for you: > >> > >> -- > >> from sqlobject import * > >> connection_string = 'mysql://dev@localhost/bd' > >> connection = connectionForURI(connection_string) > >> > >> class Centro(SQLObject): > >> _connection = connection > >> descripCentro = StringCol() > >> practicas = SQLRelatedJoin('Practica', createRelatedTable=False) > >> > >> class Practica(SQLObject): > >> _connection = connection > >> descripPractica = StringCol() > >> valorTotalPractica = FloatCol() > >> centros = SQLRelatedJoin('Centro', createRelatedTable=False) > >> > >> class PracticaCentro(SQLObject): > >> _connection = connection > >> class sqlmeta: > >> table = 'centro_practica' > >> practica = ForeignKey('Practica', notNull=True, cascade=True) > >> centro = ForeignKey('Centro', notNull=True, cascade=True) > >> estate = StringCol() > >> unique = index.DatabaseIndex(practica, centro, unique=True) > >> == > >> > >> > >> SQLRelatedJoins have a filter() method that comes in handy. > >> filter() example: > >> > >> -- > >> ## Get a Practica record from the database > >> myPractica = Practica.get(1) > >> > >> ## Get the related Centros > >> myCentros = myPractica.centros > >> > >> ## Get a filtered list of the related Centros > >> ## Where descripCentro = 'Blah' > >> myCentrosFiltered = myPractica.centros.filter( > >> AND(Centro.q.descripCentro == 'Blah')) > >> == > >> > >> Hope this helps. > >> > >> -- > >> Rick > >> > > > > ------------------------------------------------------------------------- > > Using Tomcat but need to do more? Need to support web services, security? > > Get stuff done quickly with pre-integrated technology to make your job easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > sqlobject-discuss mailing list > > sql...@li... > > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > > > |