Re: [sqlalchemy] dialect issue with pyodbc.Row type

2018-01-07 Thread Russ Wilson
I noticed if you use the cursor.fetchmany it returns the pyodbc types. Is this an issue with the dialect? if you use the connection execute you are correct it returns a resultrow. Thanks for the help. cursor = connection.cursor() cursor.execute("SELECT * FROM mytable") results_one =

[sqlalchemy] Re: Trouble eager loading with inheritance mapping

2018-01-07 Thread Theron Luhn
Okay, looks like I found the solution: all_employee_types = with_polymorphic(Employee, '*') db.query(Company).filter(Company.id == 1).options( subqueryload(Company.employees.of_type(all_employee_types)).subqueryload (all_employee_types.Engineer.machines) ) On Sunday, January 7, 2018 at

[sqlalchemy] Trouble eager loading with inheritance mapping

2018-01-07 Thread Theron Luhn
I'll be using the mappings laid out in http://docs.sqlalchemy.org/en/latest/orm/inheritance.html for my examples. "Employee" is configured with "with_polymorphic": "*" So if I were to do a query like so: db.query(Company).filter(Company.id == 1).options(subqueryload('employee')) The eager

Re: [sqlalchemy] dialect issue with pyodbc.Row type

2018-01-07 Thread Mike Bayer
On Jan 7, 2018 11:29 AM, "Russ Wilson" wrote: When I attempt to create a panda dataframe from the results it throws this error "Shape of passed values is (1, 100), indices imply (9, 100)" because it is seeing the results as 1 column vs a list of columns. Ill take a look at

Re: [sqlalchemy] dialect issue with pyodbc.Row type

2018-01-07 Thread Russ Wilson
When I attempt to create a panda dataframe from the results it throws this error "Shape of passed values is (1, 100), indices imply (9, 100)" because it is seeing the results as 1 column vs a list of columns. Ill take a look at the SQL Server one. Thanks pd.DataFrame(data=data,

[sqlalchemy] Re: Join on filter for chained loads

2018-01-07 Thread Erol Merdanović
Hello Jonathan Yes, I was suspecting that aliased was the solution but wasn't sure if it's the correct approach. It works, thank you for your help! On Saturday, 6 January 2018 18:52:54 UTC+1, Jonathan Vanasco wrote: > > use `sqlalchemy.orm.aliased` to create an alias of A for your join >

Re: [sqlalchemy] Supplying a custom autoincrement value in custom dialects

2018-01-07 Thread Florian Apolloner
As an addition to the previous mail: I am going full circles here. If I add: ``` def get_insert_default(self, column): if (column.primary_key and column is column.table._autoincrement_column and column.default is None or (isinstance(column.default,

Re: [sqlalchemy] Supplying a custom autoincrement value in custom dialects

2018-01-07 Thread Florian Apolloner
On Sunday, January 7, 2018 at 12:07:13 AM UTC+1, Mike Bayer wrote: > > 1. will you always use sequences? > No, my dialect tries to use sequences only when the are explicitly specified, otherwise it tries to use SERIAL. So: Column('id', Integer, Sequence('some_id_seq'), primary_key=True) uses