Re: [sqlalchemy] copy tables with circular dependency

2015-12-10 Thread Mike Bayer
On 12/10/2015 08:02 AM, Leily Zafari wrote: > Hello, > I want to copy some tables from one database to another using > SQLAlchemy. The tables have circular dependency which is resolved by > use_alter attribute. > > > class Product(Base): > __tablename__ = 'products' >

Re: [sqlalchemy] table_per_relation ORM example and declarative objects

2015-12-10 Thread Mike Bayer
On 12/10/2015 10:21 AM, Michal Petrucha wrote: > Hello alchemists, > > There's something that's been bugging me for a while now. I even > asked about it on [stackoverflow][1], but it didn't get much > attention there. It's been suggested to me on IRC that this > mailing list might be a better

RE: Alter boolean column on Oracle

2015-12-10 Thread Ofir Herzas
Thanks Mike. It seems that I'm in the worst case :) I've started using Sqlalchemy before the naming convention feature was introduced and so I didn't use it. A while back when I wanted to port my code to using it, I didn't find an easy way to do it and so I decided not to do it. My application

Re: [sqlalchemy] Table object to mapped class (model)

2015-12-10 Thread Simon King
On Thu, Dec 10, 2015 at 5:35 AM, Nana Okyere wrote: > I'm using the sqlalchemy-datatables library to be able to display > tabular data with the jquery datatables library. One of the parameters that > I need to create a DataTables object is a mapped class (model) as >

[sqlalchemy] control over metadata reflect

2015-12-10 Thread mdob
metadata = MetaData() metadata.reflect(engine) Base = automap_base(metadata=metadata) Base.prepare() That did a real nice job but I wanted to skip some columns from being mapped (binary types actually at the moment) I see metadata.tables['TableName'].columns to be ImmutableColumnCollection so

[sqlalchemy] Re: control over metadata reflect

2015-12-10 Thread mdob
I have tried column_reflect event and couldn't skip column. Like you said. I'll have to go a bit dipper and see how do events actually work. I tried at first to use exclude_columns but they're not acquired from kwargs in Table._init. The _autoload is called without exclude_columns argument

RE: Alter boolean column on Oracle

2015-12-10 Thread Ofir Herzas
BTW, A little bit off topic but how does the naming convention support character limitations such as the 30 characters max length for the foreign keys in Oracle? Does it provide any hooks? -Original Message- From: sqlalchemy-alembic@googlegroups.com

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread 'Robert Forkel' via sqlalchemy
As stated in the docs: "Note that any name not known to func generates the function name as is - there is no restriction on what SQL functions can be called, known or unknown to SQLAlchemy, built-in or

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread SF Markus Elfring
Thanks for the link to information I was looking for: http://stackoverflow.com/questions/15743121/how-to-filter-in-sqlalchemy-by-string-length#answer-15743220 Why is the method "length" not mentioned in the documentation chapter "SQL and Generic Functions" so far?

Re: Alter boolean column on Oracle

2015-12-10 Thread Mike Bayer
On 12/10/2015 08:39 AM, Ofir Herzas wrote: > I'm trying to run an alter_column operation from a Boolean type column > to SmallInteger on Oracle. > > According to the documentation: "...Type changes which are against the > SQLAlchemy “schema” types |Boolean| >

Re: [sqlalchemy] Re: control over metadata reflect

2015-12-10 Thread Mike Bayer
On 12/10/2015 08:06 AM, mdob wrote: > I think I got it. > > | > ||metadata =MetaData() > ||insp =reflection.Inspector.from_engine(engine) > fortable_name ininsp.get_table_names(self.db_schema): > columns =[col['name']forcol >

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread Jonathan Vanasco
`sqlalchemy.func` does not map anything. It is a namespace for a factory generator. anything you access with it becomes a function of that caller's name. for example: filter( func.foo(table.column) > 1 ) produces WHERE foo(table.column) > 1 sqlalchemy generates the `foo`

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread 'Robert Forkel' via sqlalchemy
I don't know which database you are using, but in postgresql there certainly is a function called "length" (see http://www.postgresql.org/docs/9.1/static/functions-string.html) On Thu, Dec 10, 2015 at 2:04 PM, SF Markus Elfring < elfr...@users.sourceforge.net> wrote: > > As stated in the docs: >

Alter boolean column on Oracle

2015-12-10 Thread Ofir Herzas
I'm trying to run an alter_column operation from a Boolean type column to SmallInteger on Oracle. According to the documentation: "...Type changes which are against the SQLAlchemy “schema” types Boolean and Enum

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread SF Markus Elfring
> As stated in the docs: > "Note that any name not known to func generates the function name as is > - there is no restriction on what SQL functions can be called, > known or unknown to SQLAlchemy, built-in or user defined." I get an error message like "Function len(text) does not exist." if I

[sqlalchemy] copy tables with circular dependency

2015-12-10 Thread Leily Zafari
Hello, I want to copy some tables from one database to another using SQLAlchemy. The tables have circular dependency which is resolved by use_alter attribute. class Product(Base): __tablename__ = 'products' Int_Class_ID = Column(Integer, primary_key=True) components =

[sqlalchemy] Re: control over metadata reflect

2015-12-10 Thread mdob
I think I got it. metadata = MetaData() insp = reflection.Inspector.from_engine(engine) for table_name in insp.get_table_names(self.db_schema): columns = [col['name'] for col in insp.get_columns(table_name, self. db_schema) if not isinstance(col['type'], IMAGE)] Table(table_name,

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread SF Markus Elfring
> I don't know which database you are using, > but in postgresql there certainly is a function called "length" How do you think about to avoid the direct reuse of functions which are specific for a few database software implementations? Is there any more portability possible around string

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread Mike Bayer
On 12/10/2015 12:08 PM, Jonathan Vanasco wrote: > `sqlalchemy.func` does not map anything. It is a namespace for a > factory generator. anything you access with it becomes a function of > that caller's name. > > for example: > > filter( func.foo(table.column) > 1 ) > > produces > >

[sqlalchemy] table_per_relation ORM example and declarative objects

2015-12-10 Thread Michal Petrucha
Hello alchemists, There's something that's been bugging me for a while now. I even asked about it on [stackoverflow][1], but it didn't get much attention there. It's been suggested to me on IRC that this mailing list might be a better place for this question. When you take a look at the