Re: [sqlalchemy] Not loading a kind of elements

2011-02-02 Thread slothy Rulez a lot
It's working!!!, thanks!

2011/2/1 Michael Bayer mike...@zzzcomputing.com

 The query itself has to not load the row in the first place.  There's a
 recipe for that here:

 http://www.sqlalchemy.org/trac/wiki/UsageRecipes/PreFilteredQuery


 On Feb 1, 2011, at 11:46 AM, slothy Rulez a lot wrote:

 Hi, list!

 I'm trying, to discriminate certain type of rows in the database, in a
 table with various attributes, if one attribute, ej: active =
 Column(Boolean) is set to False, I don't want it to appear in any kind of
 query, but still present in the DB.

 My first attempt is define a reconstructor like this:

 @orm.reconstructor
 def init_onload(self):
 if not self.active:
 Session.expunge(self)
 Session.commit()

 But, objects still appear.

 Any idea?

 Thanks, and as always, sorry by my poor English.

 --
 Alex.
 Slothy, the Angry Wombat
 http://angrywombat.comuv.com/portfolio/


 --
 You received this message because you are subscribed to the Google Groups
 sqlalchemy group.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 To unsubscribe from this group, send email to
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 sqlalchemy group.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 To unsubscribe from this group, send email to
 sqlalchemy+unsubscr...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.




-- 
Alex.
Slothy, the Angry Wombat
http://angrywombat.comuv.com/portfolio/

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Multilingual Model

2011-02-02 Thread Madhu Alagu
Hi

I am looking best model for the following tables:

-
---Table : groups_t
-

CREATE TABLE groups_t
(
  id BIGINT NOT NULL,
  code VARCHAR NOT NULL,
  version BIGINT NOT NULL
);

-
---Table : groups_i18n_t
-

CREATE TABLE groups_i18n_t
(
  group_id BIGINT NOT NULL,
  lang_id BIGINT NOT NULL,
  description TEXT NOT NULL,
  version BIGINT NOT NULL
);

-
---Table : groups_lookup_t
-

CREATE TABLE groups_lookup_t
(
group_id BIGINT NOT NULL,
lang_id BIGINT NOT NULL,
code VARCHAR NOT NULL,
description TEXT NOT NULL,
lookup_text TEXT NOT NULL
);

Thanks

Madhu Alagu

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] sqlalchemy, sequel server 2008, and python 3

2011-02-02 Thread Jonathan Cox
I'm a newbie trying to set up a development/learning environment with
sequel server 2008. I have a few questions:

  -is it possible to use sqlalchemy to interface with with sequel
server 2008 on Python 3.1? It seems like sqlalchemy uses some
intermediate modules (e.g., pymssql) to talk to the server, and none
of these modules are Py3 compatible. Do I have to revert back to
Python 2.? to use sqlalchemy (or any database module, it seems) with
microsoft sequel server? If I can use Python 3.1, how do I do it?

-If I have to use Python 2.? to utilize sqlalchemy and sequel server
2008, how do I install SQLAlchemy to my python 2 installation? The
setup program only pops it into my python 3 installation, and I'm not
sure how to target it elsewhere.

Many Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] sqlalchemy, sequel server 2008, and python 3

2011-02-02 Thread Michael Bayer

On Feb 2, 2011, at 3:07 PM, Jonathan Cox wrote:

 I'm a newbie trying to set up a development/learning environment with
 sequel server 2008. I have a few questions:
 
  -is it possible to use sqlalchemy to interface with with sequel
 server 2008 on Python 3.1?

not as of yet as there are no DBAPI implementations for Python 3 and SQL 
Server, or at least none we have been able to test with.   You can check the 
status of database support at 
http://www.sqlalchemy.org/docs/core/engines.html#supported-databases .

 It seems like sqlalchemy uses some
 intermediate modules (e.g., pymssql) to talk to the server, and none
 of these modules are Py3 compatible. Do I have to revert back to
 Python 2.?

if you want to use SQL Server, then for the moment, probably.There are 
DBAPIs for SQLite, Postgresql, MySQL at the moment in Python 3.


 
 -If I have to use Python 2.? to utilize sqlalchemy and sequel server
 2008, how do I install SQLAlchemy to my python 2 installation? The
 setup program only pops it into my python 3 installation, and I'm not
 sure how to target it elsewhere.

Python works based on which Python interpreter you're using.If you for 
example use pip or easy_install, there is one front-end for each version of 
python.   On my system I have easy_install-3.2 and easy_install-2.7, for 
example (thats just how the OSX installers put it in, if you're on an RPM /apt 
system, which im guessing is the case, they likely have some different 
convention).

If you are just running setup.py install, again you'd run the python 
interpreter you want:

/path/to/python2 setup.py install




-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] autoloading with known columns

2011-02-02 Thread A.M.
Hello,

I am using autoload to load some of my application metadata for views, however, 
since some information cannot be extracted from the view (such as the primary 
key) and  because one UserDefinedType I am using cannot be recognized using 
reflection, I am passing certain column information into the Table __init__ 
method:

Table(viewname,
metadata,
Column('id',Integer,primary_key=True),
Column('acl',ACLItemArrayType,nullable=False),
autoload=True)

Unfortunately, I still get Did not recognize type 'aclitem' of column 'acl' 
because the column information is still trying to be reflected. Would it make 
sense for there to exist an option to exclude column names as part of table 
reflection and exclude those columns which are specified as part of Table()?

Cheers,
M

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: autoloading with known columns

2011-02-02 Thread A.M.

On Feb 2, 2011, at 4:50 PM, A.M. wrote:

 Hello,
 
 I am using autoload to load some of my application metadata for views, 
 however, since some information cannot be extracted from the view (such as 
 the primary key) and  because one UserDefinedType I am using cannot be 
 recognized using reflection, I am passing certain column information into the 
 Table __init__ method:
 
 Table(viewname,
   metadata,
   Column('id',Integer,primary_key=True),
   Column('acl',ACLItemArrayType,nullable=False),
   autoload=True)
 
 Unfortunately, I still get Did not recognize type 'aclitem' of column 'acl' 
 because the column information is still trying to be reflected. Would it make 
 sense for there to exist an option to exclude column names as part of table 
 reflection and exclude those columns which are specified as part of Table()?

Also, it might be useful to register UserDefinedTypes with an inspector to 
autoload UserDefinedTypes through an additional reverse get_col_spec method.

Cheers,
M

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] autoloading with known columns

2011-02-02 Thread Michael Bayer

On Feb 2, 2011, at 4:50 PM, A.M. wrote:

 Hello,
 
 I am using autoload to load some of my application metadata for views, 
 however, since some information cannot be extracted from the view (such as 
 the primary key) and  because one UserDefinedType I am using cannot be 
 recognized using reflection, I am passing certain column information into the 
 Table __init__ method:
 
 Table(viewname,
   metadata,
   Column('id',Integer,primary_key=True),
   Column('acl',ACLItemArrayType,nullable=False),
   autoload=True)
 
 Unfortunately, I still get Did not recognize type 'aclitem' of column 'acl' 
 because the column information is still trying to be reflected.

it will emit that warning when it loads the full set of columns, but your 
ACLItemArrayType should be written into the Table metadata for the end result.

 Would it make sense for there to exist an option to exclude column names as 
 part of table reflection and exclude those columns which are specified as 
 part of Table()?

We currently have include_columns as a Table argument which works in the 
opposite direction, exclude_columns is doable, but the better solution here 
would be to allow you to register your new type with the dialect.   You can 
achieve that now through non-public API by adding PG's internal identifier for 
the type plus your type to ischema_names:

engine = create_engine('postgresql://')
engine.dialect.ischema_names['ACLARRAY'] = ACLItemArrayType





 
 Cheers,
 M
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.