Re: [sqlalchemy] Syntax Error with Dialect kwargs

2017-04-05 Thread mike bayer
this would be a bug since we do have a list of entries that are dependent on each other, so orderings like these need to be coded. https://bitbucket.org/zzzeek/sqlalchemy/issues/3961/mysql-partition-options-need-to-be-after is added which per the syntax diagram moves all the partition options

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2017-04-05 Thread mike bayer
On 04/05/2017 07:42 PM, davor wrote: It seems that besides name_for_scalar_relationship also generate_relationship has to be adjusted since the backref name will also not be unique. name_for_collection_relationship is usually what you need for bi-directional many-to-many Are here any

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2017-04-05 Thread davor
It seems that besides name_for_scalar_relationship also generate_relationship has to be adjusted since the backref name will also not be unique. Are here any options to make the name more unique? On Wednesday, 6 January 2016 11:43:54 UTC+1, yoch@gmail.com wrote: > > For now, I don't have

[sqlalchemy] Syntax Error with Dialect kwargs

2017-04-05 Thread T Johnson
I have a script.py that does roughly this: import sqlalchemy as sa engine = ... part_text = """RANGE COLUMNS (my_date) ( PARTITION p20161017 VALUES LESS THAN ('2016-10-18'), PARTITION p20161018 VALUES LESS THAN ('2016-10-19'), PARTITION p1231 VALUES LESS THAN (MAXVALUE) )""" t

[sqlalchemy] duplicate entry with session.merge

2017-04-05 Thread jean-yves . pasquier
I use sqlalchemy to perform to insert and upsert of rows. During certain requests for many tables I get an IntegrityError duplicate entry when using session.merge(obj). I tried to find an answer on the web and on the IRC but I came back empty-handed. I'm using python 2.7, alembic 0.9.1 and

[sqlalchemy] Re: Column definition and database having different string length fields

2017-04-05 Thread Jonathan Vanasco
Just to expand on Mike's answer... I've run into this often on a handful of columns. The solution I've settled on is to set a variable: COLUMN_SIZE_SERVERSIDE = 1 and then use that as the length on the problematic column sizes while I work out the issues on what the length should be, and

Re: [sqlalchemy] Column definition and database having different string length fields

2017-04-05 Thread mike bayer
Hi there - the length that's in your String() type is not used by SQLAlchemy except when it first renders DDL for CREATE TABLE, so to that extent it is safe for the database column itself to be of a different size. This wouldn't account for something like a client-side validation rule that

Re: [sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Mayank Soni
> > Thank you very much . Sure , I will try this -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a

Re: [sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Simon King
If the column names are part of the "schools_master" table, then the easiest option is something like this: q = session.query(AAA).limit(100) for row in q: for name in col_names: print '%s = %' % (name, getattr(row, name)) Alternatively: cols = [getattr(AAA, name) for name in

[sqlalchemy] Re: How to pass list of columns into query method.

2017-04-05 Thread Mayank Soni
Thanks Simon ..it works -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You

Re: [sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Mayank Soni
Thanks Simon for response. Actually column names I am getting from user interface based on user selection that is why i want pass columns in query method dynamically. can you suggest me how can achieve this. On Wednesday, April 5, 2017 at 5:08:50 PM UTC+5:30, Simon King wrote: > > On Wed,

Re: [sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Simon King
On Wed, Apr 5, 2017 at 11:10 AM, Mayank Soni wrote: > I am trying to pass list of columns of table into query method using > add_columns method. Below i am mentioning code snipped. > > def LLL(): > Base = automap_base() > class AAA(Base): > __tablename__ =

[sqlalchemy] Column definition and database having different string length fields

2017-04-05 Thread Dave
Hello, I have an application that is throwing exceptions on insert because one of the columns was defined too short. sqlalchemy.exc.DataError: (psycopg2.DataError) value too long for type character varying(50) The model is defined as: class Device(Base): processor = Column(String(50))

[sqlalchemy] How to pass list of columns into query method.

2017-04-05 Thread Mayank Soni
I am trying to pass list of columns of table into query method using add_columns method. Below i am mentioning code snipped. def LLL(): Base = automap_base() class AAA(Base): __tablename__ = 'schools_master' Base.prepare(engine, reflect=True) session =