Re: [sqlalchemy] Pyodbc.Connection has no attribute 'dbms_ver'?

2016-02-14 Thread Jaimy Azle
Try to use ibm_db_sa 0.3.2 instead, apparently you are using the previous
version. dbms_ver is a feature specific of native ibm_db version of which
not available in pyodbc.

https://pypi.python.org/pypi/ibm_db_sa/0.3.2


Salam,

-Jaimy.


On Feb 12, 2016 22:05, "Alex Hall"  wrote:

> Hello list,
> I've configured a DSN to a test version of my work's AS400 and I seem
> to be able to connect just fine (Yes!) I'm now running into a problem
> when I try to ask for a list of all tables. The line is:
>
>  dbInspector = inspect(dbEngine)
>
> The traceback is very long, and I can paste it if you want, but it
> ends with this:
>
> AttributeError: 'pyodbc.Connection' object has no attribute 'dbms_ver'
>
> I'm unable to find anything about this online, so thought I'd check
> with this list. Here's my connection:
>
> dbEngine = create_engine("ibm_db_sa+pyodbc://user:pwd@myDSN")
>
> If anyone knows what is causing this, I'd appreciate your thoughts.
> I've installed pyodbc, ibm_db, and ibm_db_sa through pip, so I should
> have all the latest versions of everything. I'm on Windows 7x64,
> Python 2.7 (latest).
>
> --
> 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 sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Re: best way to declare one-to-one relationships with automap and non-explicit relationships

2016-02-14 Thread Mike Bayer



On 02/14/2016 06:13 PM, Brian Cherinka wrote:




you'd need to implement a generate_relationship function as
described at

http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/automap.html#custom-relationship-arguments


which applies the rules you want in order to establish those
relationships that you'd like to be one-to-one.

Yeah, that's what I tried to do here, but it appeared to do nothing.
  That documentation isn't entirely clear I'm afraid.  The direction
input doesn't have an interaction.ONETOONE option, so I tried to find an
alternative way of identifying which tables needed a one-to-one
relationship.  Having a look, I don't think this function works as is
because I don't define the pair of tables (from local_cls, referred_cls)
that are in a one-to-one.  I only define one in my onetoones list.


OK so if you suggest edits to the documentation here, that would help. 
Below is a working example where I basically cut-and-pasted directly 
from the documentation example.  The import for 
"sqlalchemy.orm.interfaces" is missing, otherwise everything works as 
advertised just by changing the arguments in the example to match the 
use case.   Let me know what needs clarification here, thanks!



from sqlalchemy import create_engine

e = create_engine("sqlite://", echo=True)
e.execute("""
create table a (id integer primary key, data varchar)
""")
e.execute("""
create table b (id integer primary key, data varchar,
foreign key (id) references a(id))
""")

# now i cut and paste from the automap docs at
# 
http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/automap.html#custom-relationship-arguments


from sqlalchemy.ext.automap import generate_relationship

# this import is missing from the docs, OK.
from sqlalchemy.orm import interfaces

def _gen_relationship(
base, direction, return_fn,
attrname, local_cls, referred_cls, **kw):
if direction is interfaces.ONETOMANY:
# I change this line
kw['uselist'] = False

# default naming scheme for onetomany will
# come up with "_collection", so chop that
# off assuming we want to do onetoone
if attrname.endswith("_collection"):
attrname = attrname[:-11]

return generate_relationship(base, direction, return_fn,
 attrname, local_cls, referred_cls, **kw)

from sqlalchemy.ext.automap import automap_base

Base = automap_base()

# change this to point to the engine above
Base.prepare(
e, reflect=True,
generate_relationship=_gen_relationship)

# end-cut and paste. now im using it
A = Base.classes.a
B = Base.classes.b

from sqlalchemy.orm import Session


s = Session(e)

s.add(A(data="some a", b=B(data="some b")))

s.commit()

a1 = s.query(A).first()
assert a1.b.data == "some b"







onetoones = ['file']

def _gen_relationship(base, direction, return_fn, attrname, local_cls,
referred_cls, **kw):
 if local_cls.__table__.name in onetoones:
 kw['uselist'] = False
 # make use of the built-in function to actually return the result.
 return generate_relationship(base, direction, return_fn, attrname,
local_cls, referred_cls, **kw)



  Here is what I'm trying so far, but it's not working.



I don't see anything obviously wrong with it but you'd want to step
through with pdb.set_trace() to ensure every aspect of it is doing
what you'd expect.   Otherwise "not working" can mean lots of things.

Ok.  Well I'll keep digging around.




onetoones = ['file']

def _gen_relationship(base, direction, return_fn, attrname,
local_cls, referred_cls, **kw):
 if local_cls.__table__.name in onetoones:
 kw['uselist'] = False
 # make use of the built-in function to actually return the
result.
 return generate_relationship(base, direction, return_fn,
attrname, local_cls, referred_cls, **kw)

def camelizeClassName(base, tablename, table):
 return str(tablename[0].upper() + re.sub(r'_([a-z])',
lambda m: m.group(1).upper(), tablename[1:]))

_pluralizer = inflect.engine()
def pluralize_collection(base, local_cls, referred_cls, constraint):
 referred_name = referred_cls.__name__
 uncamelized = re.sub(r'[A-Z]', lambda m: "_%s" %
m.group(0).lower(), referred_name)[1:]
 pluralized = _pluralizer.plural(uncamelized)
 return pluralized

# Grabs engine
db = DatabaseConnection()
engine = db.engine

# Selects schema and automaps it.
metadata = MetaData(schema='mangadapdb')
Base = automap_base(bind=engine, metadata=metadata)

# Pre-define Dap class.  Necessary so automap knows to join this
table to a declarative base class from another schema
class 

Re: [sqlalchemy] proper attribute names for many-to-many relationships using automap

2016-02-14 Thread Mike Bayer



On 02/14/2016 05:01 PM, Brian Cherinka wrote:
What is the proper way to get pluralized shortened names for 
many-to-many tables when using automap?  I currently have it set to 
generate pluralized lowercase names for collections instead of the 
default "_collection".  This is what I want for one-to-many or 
many-to-one relationships, but not many-to-many.  For example, I have 
two tables, hdu, and extcol, joined together through a many-to-many 
table, hdu_to_extcol


|
create table hdu (pk serial primary key notnull,extname_pk 
integer,exttype_pk integer,extno integer,file_pk integer);
create table hdu_to_extcol (pk serial primary key notnull,hdu_pk 
integer,extcol_pk integer);

create table extcol (pk serial primary key notnull,name text);

ALTER TABLE ONLY mangadapdb.hdu_to_extcol
ADD CONSTRAINT hdu_fk
FOREIGN KEY (hdu_pk)REFERENCES mangadapdb.hdu(pk)
ON UPDATE CASCADE ON DELETE CASCADE;

ALTER TABLE ONLY mangadapdb.hdu_to_extcol
ADD CONSTRAINT extcol_fk
FOREIGN KEY (extcol_pk)REFERENCES mangadapdb.extcol(pk)
ON UPDATE CASCADE ON DELETE CASCADE;
|

When I use SQLalchemy to automap the Base classes, the relationship 
this generates on the Hdu and Extcol classes are *Hdu.hdu_to_extcol, 
and Extcol.hdu_to_extcols*, using the below pluralize, and 
relationship, code.  However, ideally what I'd like the names to be 
are *Hdu.extcols, and Extcol.hdus*, respectively.  What's the best to 
generate this for these many-to-many tables?   I'm not sure if automap 
is recognizing these as many-to-many tables.  The direction indicated 
when I print during the relationship stage don't indicate as such.


symbol('ONETOMANY')  extcol
symbol('MANYTOONE')  
hdu_to_extcol

symbol('ONETOMANY')  hdu
symbol('MANYTOONE')  
hdu_to_extcol


many-to-many is detected based on a specific configuration of table 
described at 
http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/automap.html#many-to-many-relationships. 
The table must have two foreign key constraints set up and all columns 
must be members of these constraints.  In this case, hdu_to_extcol 
contains a surrogate primary key "pk" which disqualifies it as a typical 
"many to many" table, and instead automap will assume it's a mapped entity.


To establish these relationships manually you can just add the 
relationship() with "secondary" argument that you want onto the 
appropriate class which you'd pre-declare.   The mappings that automap 
generates can just be ignored.


Otherwise, if you really don't want to "pre-declare" but instead have 
some kind of lookup table, you can intercept classes as they are mapped 
using an event like mapper_configured 
(http://docs.sqlalchemy.org/en/rel_1_0/orm/events.html?highlight=orm%20events#sqlalchemy.orm.events.MapperEvents.mapper_configured), 
check them against your lookup, and add additional relationships as desired.


automap is intended for the use case of quickly building up a mapping to 
get at some existing, possibly legacy, database where it's not really 
worth building up complete explicit classes.  But because it's designed 
for expediency, it isn't intended to deliver perfection.  If you have 
very specific ORM mapping patterns that you'd like to see on top of 
existing tables, the best way to do that is to map them explicitly using 
normal Declarative directives.   Let automap just fill in all the extra 
columns that aren't so important, but structural stuff is going to be 
easier just to set up explicitly.






Here is my Base class generation code.

|
def_gen_relationship(base,direction,return_fn,attrname,local_cls,referred_cls,**kw):
iflocal_cls.__table__.name inonetoones:
kw['uselist']=False
# make use of the built-in function to actually return the result.

returngenerate_relationship(base,direction,return_fn,attrname,local_cls,referred_cls,**kw)

_pluralizer =inflect.engine()
defpluralize_collection(base,local_cls,referred_cls,constraint):
referred_name =referred_cls.__name__
uncamelized 
=re.sub(r'[A-Z]',lambdam:"_%s"%m.group(0).lower(),referred_name)[1:]

pluralized =_pluralizer.plural(uncamelized)
returnpluralized

# Grabs engine
db =DatabaseConnection()
engine =db.engine

# Selects schema and automaps it.
metadata =MetaData(schema='mangadapdb')
Base=automap_base(bind=engine,metadata=metadata)
Base.prepare(engine,reflect=True,classname_for_table=camelizeClassName,name_for_collection_relationship=pluralize_collection,generate_relationship=_gen_relationship)

# Explicitly declare classes
forcl inBase.classes.keys():
exec('{0} = Base.classes.{0}'.format(cl))

|



--
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 sqlalchemy+unsubscr...@googlegroups.com 
.
To post to this group, send email to sqlalchemy@googlegroups.com 
.

Visit this group at 

[sqlalchemy] Re: best way to declare one-to-one relationships with automap and non-explicit relationships

2016-02-14 Thread Michael Bayer


On Sunday, February 14, 2016 at 4:12:36 PM UTC-5, Brian Cherinka wrote:
>
> Hi, 
>
> I'm trying to use automap a schema, and let it generate all classes and 
> relationships between my tables.  It seems to work well for all 
> relationships except for one-to-one
>  I know to set a one-to-one relationship, you must apply the uselist=True 
> keyword in relationship().  What's the best way to do that when I'm letting 
> automap generate them?  Without having to manually do it myself by removing 
> the automap generated ones, and setting them explicitly.  
>
 

you'd need to implement a generate_relationship function as described at 
http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/automap.html#custom-relationship-arguments
 
which applies the rules you want in order to establish those relationships 
that you'd like to be one-to-one.

 

 Here is what I'm trying so far, but it's not working. 
>


I don't see anything obviously wrong with it but you'd want to step through 
with pdb.set_trace() to ensure every aspect of it is doing what you'd 
expect.   Otherwise "not working" can mean lots of things.

 

>  
>  
>


> onetoones = ['file']
>
> def _gen_relationship(base, direction, return_fn, attrname, local_cls, 
> referred_cls, **kw):
> if local_cls.__table__.name in onetoones:
> kw['uselist'] = False
> # make use of the built-in function to actually return the result.
> return generate_relationship(base, direction, return_fn, attrname, 
> local_cls, referred_cls, **kw)
>
> def camelizeClassName(base, tablename, table):
> return str(tablename[0].upper() + re.sub(r'_([a-z])', lambda m: 
> m.group(1).upper(), tablename[1:]))
>
> _pluralizer = inflect.engine()
> def pluralize_collection(base, local_cls, referred_cls, constraint):
> referred_name = referred_cls.__name__
> uncamelized = re.sub(r'[A-Z]', lambda m: "_%s" % m.group(0).lower(), 
> referred_name)[1:]
> pluralized = _pluralizer.plural(uncamelized)
> return pluralized
>
> # Grabs engine
> db = DatabaseConnection()
> engine = db.engine
>
> # Selects schema and automaps it.
> metadata = MetaData(schema='mangadapdb')
> Base = automap_base(bind=engine, metadata=metadata)
>
> # Pre-define Dap class.  Necessary so automap knows to join this table to 
> a declarative base class from another schema
> class Dap(Base):
> __tablename__ = 'dap'
>
> cube_pk = Column(Integer, ForeignKey(datadb.Cube.pk))
> cube = relationship(datadb.Cube, backref='dap', uselist=False)
>
> # Prepare the base
> Base.prepare(engine, reflect=True, classname_for_table=camelizeClassName, 
> name_for_collection_relationship=pluralize_collection, 
> generate_relationship=_gen_relationship)
>
> # Explicitly declare classes
> for cl in Base.classes.keys():
> exec('{0} = Base.classes.{0}'.format(cl))
>
>

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] proper attribute names for many-to-many relationships using automap

2016-02-14 Thread Brian Cherinka
What is the proper way to get pluralized shortened names for many-to-many 
tables when using automap?  I currently have it set to generate pluralized 
lowercase names for collections instead of the default "_collection".  This 
is what I want for one-to-many or many-to-one relationships, but not 
many-to-many.  For example, I have two tables, hdu, and extcol, joined 
together through a many-to-many table, hdu_to_extcol

create table hdu (pk serial primary key not null, extname_pk integer, 
exttype_pk integer, extno integer, file_pk integer);
create table hdu_to_extcol (pk serial primary key not null, hdu_pk integer, 
extcol_pk integer);
create table extcol (pk serial primary key not null, name text);

ALTER TABLE ONLY mangadapdb.hdu_to_extcol
ADD CONSTRAINT hdu_fk
FOREIGN KEY (hdu_pk) REFERENCES mangadapdb.hdu(pk)
ON UPDATE CASCADE ON DELETE CASCADE;

ALTER TABLE ONLY mangadapdb.hdu_to_extcol
ADD CONSTRAINT extcol_fk
FOREIGN KEY (extcol_pk) REFERENCES mangadapdb.extcol(pk)
ON UPDATE CASCADE ON DELETE CASCADE;

When I use SQLalchemy to automap the Base classes, the relationship this 
generates on the Hdu and Extcol classes are *Hdu.hdu_to_extcol, and 
Extcol.hdu_to_extcols*, using the below pluralize, and relationship, code. 
 However, ideally what I'd like the names to be are *Hdu.extcols, and 
Extcol.hdus*, respectively.  What's the best to generate this for these 
many-to-many tables?   I'm not sure if automap is recognizing these as 
many-to-many tables.  The direction indicated when I print during the 
relationship stage don't indicate as such.

symbol('ONETOMANY')  extcol
symbol('MANYTOONE')  
hdu_to_extcol
symbol('ONETOMANY')  hdu
symbol('MANYTOONE')  
hdu_to_extcol

Here is my Base class generation code. 

def _gen_relationship(base, direction, return_fn, attrname, local_cls, 
referred_cls, **kw):
if local_cls.__table__.name in onetoones:
kw['uselist'] = False
# make use of the built-in function to actually return the result.

return generate_relationship(base, direction, return_fn, attrname, 
local_cls, referred_cls, **kw)

_pluralizer = inflect.engine()
def pluralize_collection(base, local_cls, referred_cls, constraint):
referred_name = referred_cls.__name__
uncamelized = re.sub(r'[A-Z]', lambda m: "_%s" % m.group(0).lower(),
referred_name)[1:]
pluralized = _pluralizer.plural(uncamelized)
return pluralized

# Grabs engine
db = DatabaseConnection()
engine = db.engine

# Selects schema and automaps it.
metadata = MetaData(schema='mangadapdb')
Base = automap_base(bind=engine, metadata=metadata)
Base.prepare(engine, reflect=True, classname_for_table=camelizeClassName, 
name_for_collection_relationship=pluralize_collection, generate_relationship
=_gen_relationship)

# Explicitly declare classes
for cl in Base.classes.keys():
exec('{0} = Base.classes.{0}'.format(cl))




-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] best way to declare one-to-one relationships with automap and non-explicit relationships

2016-02-14 Thread Brian Cherinka
Hi, 

I'm trying to use automap a schema, and let it generate all classes and 
relationships between my tables.  It seems to work well for all 
relationships except for one-to-one.  I know to set a one-to-one 
relationship, you must apply the uselist=True keyword in relationship(). 
 What's the best way to do that when I'm letting automap generate them? 
 Without having to manually do it myself by removing the automap generated 
ones, and setting them explicitly.  Here is what I'm trying so far, but 
it's not working. 

onetoones = ['file']

def _gen_relationship(base, direction, return_fn, attrname, local_cls, 
referred_cls, **kw):
if local_cls.__table__.name in onetoones:
kw['uselist'] = False
# make use of the built-in function to actually return the result.
return generate_relationship(base, direction, return_fn, attrname, 
local_cls, referred_cls, **kw)

def camelizeClassName(base, tablename, table):
return str(tablename[0].upper() + re.sub(r'_([a-z])', lambda m: 
m.group(1).upper(), tablename[1:]))

_pluralizer = inflect.engine()
def pluralize_collection(base, local_cls, referred_cls, constraint):
referred_name = referred_cls.__name__
uncamelized = re.sub(r'[A-Z]', lambda m: "_%s" % m.group(0).lower(), 
referred_name)[1:]
pluralized = _pluralizer.plural(uncamelized)
return pluralized

# Grabs engine
db = DatabaseConnection()
engine = db.engine

# Selects schema and automaps it.
metadata = MetaData(schema='mangadapdb')
Base = automap_base(bind=engine, metadata=metadata)

# Pre-define Dap class.  Necessary so automap knows to join this table to a 
declarative base class from another schema
class Dap(Base):
__tablename__ = 'dap'

cube_pk = Column(Integer, ForeignKey(datadb.Cube.pk))
cube = relationship(datadb.Cube, backref='dap', uselist=False)

# Prepare the base
Base.prepare(engine, reflect=True, classname_for_table=camelizeClassName, 
name_for_collection_relationship=pluralize_collection, 
generate_relationship=_gen_relationship)

# Explicitly declare classes
for cl in Base.classes.keys():
exec('{0} = Base.classes.{0}'.format(cl))

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: best way to declare one-to-one relationships with automap and non-explicit relationships

2016-02-14 Thread Brian Cherinka


>
>
> you'd need to implement a generate_relationship function as described at 
> http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/automap.html#custom-relationship-arguments
>  
> which applies the rules you want in order to establish those relationships 
> that you'd like to be one-to-one.
>
>  
Yeah, that's what I tried to do here, but it appeared to do nothing.  That 
documentation isn't entirely clear I'm afraid.  The direction input doesn't 
have an interaction.ONETOONE option, so I tried to find an alternative way 
of identifying which tables needed a one-to-one relationship.  Having a 
look, I don't think this function works as is because I don't define the 
pair of tables (from local_cls, referred_cls) that are in a one-to-one.  I 
only define one in my onetoones list.  

onetoones = ['file']

def _gen_relationship(base, direction, return_fn, attrname, local_cls, 
referred_cls, **kw):
if local_cls.__table__.name in onetoones:
kw['uselist'] = False
# make use of the built-in function to actually return the result.
return generate_relationship(base, direction, return_fn, attrname, 
local_cls, referred_cls, **kw)
 

>  
>
>  Here is what I'm trying so far, but it's not working. 
>>
>
>
> I don't see anything obviously wrong with it but you'd want to step 
> through with pdb.set_trace() to ensure every aspect of it is doing what 
> you'd expect.   Otherwise "not working" can mean lots of things.
>
>  
Ok.  Well I'll keep digging around.  
 

>  
>
>>  
>>  
>>
>
>
>> onetoones = ['file']
>>
>> def _gen_relationship(base, direction, return_fn, attrname, local_cls, 
>> referred_cls, **kw):
>> if local_cls.__table__.name in onetoones:
>> kw['uselist'] = False
>> # make use of the built-in function to actually return the result.
>> return generate_relationship(base, direction, return_fn, attrname, 
>> local_cls, referred_cls, **kw)
>>
>> def camelizeClassName(base, tablename, table):
>> return str(tablename[0].upper() + re.sub(r'_([a-z])', lambda m: 
>> m.group(1).upper(), tablename[1:]))
>>
>> _pluralizer = inflect.engine()
>> def pluralize_collection(base, local_cls, referred_cls, constraint):
>> referred_name = referred_cls.__name__
>> uncamelized = re.sub(r'[A-Z]', lambda m: "_%s" % m.group(0).lower(), 
>> referred_name)[1:]
>> pluralized = _pluralizer.plural(uncamelized)
>> return pluralized
>>
>> # Grabs engine
>> db = DatabaseConnection()
>> engine = db.engine
>>
>> # Selects schema and automaps it.
>> metadata = MetaData(schema='mangadapdb')
>> Base = automap_base(bind=engine, metadata=metadata)
>>
>> # Pre-define Dap class.  Necessary so automap knows to join this table to 
>> a declarative base class from another schema
>> class Dap(Base):
>> __tablename__ = 'dap'
>>
>> cube_pk = Column(Integer, ForeignKey(datadb.Cube.pk))
>> cube = relationship(datadb.Cube, backref='dap', uselist=False)
>>
>> # Prepare the base
>> Base.prepare(engine, reflect=True, classname_for_table=camelizeClassName, 
>> name_for_collection_relationship=pluralize_collection, 
>> generate_relationship=_gen_relationship)
>>
>> # Explicitly declare classes
>> for cl in Base.classes.keys():
>> exec('{0} = Base.classes.{0}'.format(cl))
>>
>>

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Use order_by when using relationship() with secondary-parameter in a many-to-many?

2016-02-14 Thread c.buhtz
> >> order_by=ReferenceAuthor.c.Index)
>order_by, you spelled it wrong.

Sorry, I can not see a difference. I think I missunderstand you.

btw: What does the 'c' means?

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Use order_by when using relationship() with secondary-parameter in a many-to-many?

2016-02-14 Thread c.buhtz
On 2016-02-14 08:38 Michael Bayer  wrote:
> order_by, you spelled it wrong.

Ah, I see the misstake. Was a copy thing. Sorry.

What is this c? I havend found that "topic" in the docs. Where should I
look for?

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] Use order_by when using relationship() with secondary-parameter in a many-to-many?

2016-02-14 Thread Michal Petrucha
On Sun, Feb 14, 2016 at 03:23:59PM +0100, c.bu...@posteo.jp wrote:
> On 2016-02-14 08:38 Michael Bayer  wrote:
> > order_by, you spelled it wrong.
> 
> Ah, I see the misstake. Was a copy thing. Sorry.
> 
> What is this c? I havend found that "topic" in the docs. Where should I
> look for?

I believe what you are looking for is
http://docs.sqlalchemy.org/en/rel_1_0/core/metadata.html#sqlalchemy.schema.Table.c,
i.e. an alias for the “columns” attribute.

Cheers,

Michal

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: [sqlalchemy] Use order_by when using relationship() with secondary-parameter in a many-to-many?

2016-02-14 Thread Michael Bayer
order_by, you spelled it wrong.

> On Feb 14, 2016, at 3:53 AM,   wrote:
> 
> Hi Mike
> 
>> On 2016-02-13 14:30 Mike Bayer  wrote:
>> you can order by secondary, just add it in:
>> 
>> authors = relationship("Person", secondary=ReferenceAuthor, 
>> order_by=ReferenceAuthor.c.Index)
> 
> Are you sure? I get this error about it
> 
> TypeError: relationship() got an unexpected keyword argument 'oder_by'
> 
> -- 
> 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 sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.