On Sun, Feb 05, 2017 at 07:16:48PM +0100, janemba <[email protected]> wrote:
> Hi,
>
> I have an issue with table name. I use my own naming for class name but
> it doesn't correspond to the table
> name. So, I use sql_meta with table attribute but it doesn't work.
sqlmeta, not sql_meta.
> I have the following error :
>
> sqlobject.dberrors.ProgrammingError: Table 'foo.bar' doesn't exist
>
> Is it possible to use custom class name that do not correspond to table
> name ?
Works for me. Example:
from sqlobject import *
__connection__ = "sqlite:/:memory:?debug=1&debugOutput=1"
class Person(SQLObject):
class sqlmeta:
table = 'city_person'
name = StringCol()
pets = MultipleJoin('Animal', joinColumn='owner_id')
class Animal(SQLObject):
class sqlmeta:
table = 'city_animal'
name = StringCol()
owner = ForeignKey('Person')
Person.createTable()
Animal.createTable()
Debug output:
1/QueryR : CREATE TABLE city_person (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT
)
2/QueryR : CREATE TABLE city_animal (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
owner_id INT CONSTRAINT owner_id_exists REFERENCES city_person(id)
)
> Cheers,
Oleg.
--
Oleg Broytman http://phdru.name/ [email protected]
Programmers don't die, they just GOSUB without RETURN.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss