Suppose I have models (with corresponding tables) in pseudocode
table1
| some_unique_name | some_property |
|------------------+---------------|
| foo | 1 |
|------------------+---------------|
| bar | 2 |
|------------------+---------------|
table2
| another_unique_name | another_property |
|---------------------+------------------|
| jack | married |
|---------------------+------------------|
| marry | widow |
|---------------------+------------------|
Another database
foo_jack_some_huge_data
| kids_count | dog_coung | point_in_time |
|------------+-----------+---------------|
| 1 | 0 | 0:01 |
|------------+-----------+---------------|
| 2 | 1 | 3:00 |
|------------+-----------+---------------|
bar_jack_some_huge_data
| kids_count | dog_coung | point_in_time |
|------------+-----------+---------------|
| 2 | 0 | 0:01 |
|------------+-----------+---------------|
| 3 | 1 | 3:00 |
|------------+-----------+---------------|
foo_marry_some_huge_data
| kids_count | dog_coung | point_in_time |
|------------+-----------+---------------|
| 4 | 0 | 0:01 |
|------------+-----------+---------------|
| 5 | 1 | 3:00 |
|------------+-----------+---------------|
So what I'm trying to say that we are making a shard on
table1.some_unique_name and table2.another_unique_name.
So what I've already done is that
@lru_cache(maxsize=None)
def candles_table(some_unique_name, another_unique_name):
return Table('_'.join((some_unquie_name, another_unique_name,
'some_huge_data')), Base.metadata,
Column('kids_count', Integer),
Column('dog_count', Integer),
Column('point_in_time', DateTime),
)
this works fine but I'd like to use class and a mapper instead of raw table
object (for obvious reasons)
I saw this question
<http://stackoverflow.com/questions/19163911/dynamically-setting-tablename-for-sharding-in-sqlalchemy>,
but I don't like the solutions there.
Can I create a custom mapper class that would have api like that
mapper.map(klass, *tables)
and then somehow when quering this class via session.query I would be able
to say what tables exactly would I like to query. Like some .shard(...) or
something like that.
I haven't created the issue because I didn't know if solution (not a
workaround like mentioned in stackoverflow) already possible with
sqlalchemy. If not it would be beneficial to add I think.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.