[sqlalchemy] Documenting sqlalchemy objects via sphinx automodule

2012-09-04 Thread Sean Davis
I'm not sure there is a solution to this problem without changes to sphinx, 
but here is what I've got.  In my __init__.py, I have:

Session = sessionmaker()
Base = declarative_base()

def init_model(**kwargs):
Initialize the database model


mydb = URL(drivername='mysql',
   database='solexa',
   query= { 'read_default_file' : '~/.my.cnf' },
   **kwargs)
engine = create_engine(mydb)
 
Session.configure(bind=engine)

Base.metadata.bind=engine

import meltzdbtools.solexa.objects as objects

Then, I have a bunch of classes in objects.py that look like:

from meltzdbtools.solexa import Base

class StudyFile(Base):
__tablename__ = 'solexa_study_file'
__table_args__ = (
ForeignKeyConstraint(['study_id'], ['solexa_study.ID']),
ForeignKeyConstraint(['basecalllane_id'], 
['solexa_file.BasecallLane_ID']),
ForeignKeyConstraint(['library_id'], ['solexa_file.Library_ID']),
{autoload:True})
study = relationship('Study')

When I try to run automodule documentation on meltzdbtools.solexa.objects, 
of course init_model() has not been run, so autoloading fails and Base is 
not bound to an engine.  Any suggestions as to how to deal with this 
problem?

Thanks,
Sean

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/TeQSqXqJTz0J.
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: Cannot adapt for insert

2008-10-04 Thread Sean Davis



On Oct 3, 10:58 pm, Sean Davis [EMAIL PROTECTED] wrote:
 ProgrammingError: (ProgrammingError) can't adapt 'INSERT INTO
 runbrowser_image (id, nobj, focusmetric, focusuniformity, choffset_x,
 choffset_y, blu, flu, int_min, int_mean, int_stdev, int_max,
 int_median, int_q87, nse_min, nse_mean, nse_stdev, nse_max, base,
 tile_id) VALUES (%(id)s, %(nobj)s, %(focusmetric)s, %
 (focusuniformity)s, %(choffset_x)s, %(choffset_y)s, %(blu)s, %(flu)s, %
 (int_min)s, %(int_mean)s, %(int_stdev)s, %(int_max)s, %(int_median)s, %
 (int_q87)s, %(nse_min)s, %(nse_mean)s, %(nse_stdev)s, %(nse_max)s, %
 (base)s, %(tile_id)s)' {'int_q87': 6499.11498,
 'focusuniformity': 95.1993894, 'nse_mean': 273.3298649998,
 'int_stdev': 2763.36702, 'blu': 68.97684479995, 'nobj':
 14597, 'flu': 68.2585204, 'int_min': -1874.16735,
 'choffset_y': 0.0, 'choffset_x': 0.0, 'int_mean': 2965.79126, 'base':
 'A', 'nse_stdev': 110.751434, 'int_median': 2022.095, 'nse_min': 0.0,
 'nse_max': 732.833301, 'tile_id': 37504, 'int_max':
 19389.40429998, 'id': 2L, 'focusmetric': 77.3844693}

 The table is described as:

 class RunBrowserImage(Base):
     __tablename__ = runbrowser_image

     id = Column(Integer,primary_key=True)
     nobj = Column(Integer)
     focusmetric = Column(Float)
     focusuniformity = Column(Float)
     choffset_x = Column(Float)
     choffset_y = Column(Float)
     blu = Column(Float)
     flu = Column(Float)
     int_min = Column(Float)
     int_mean = Column(Float)
     int_stdev = Column(Float)
     int_max = Column(Float)
     int_median = Column(Float)
     int_q87 = Column(Float)
     nse_min = Column(Float)
     nse_mean = Column(Float)
     nse_stdev = Column(Float)
     nse_max = Column(Float)
     base = Column(CHAR(1))
     tile_id = Column(Integer,ForeignKey('runbrowser_tile.id'))

     tile = relation(RunBrowserTile,backref=backref('images'))

 I cannot figure out why the error.  I know it must be something
 obvious, but I can't find it.

This was due to not casting the base() column to a unicode string (or,
at least, it fixed the problem).

Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Cannot adapt for insert

2008-10-03 Thread Sean Davis

ProgrammingError: (ProgrammingError) can't adapt 'INSERT INTO
runbrowser_image (id, nobj, focusmetric, focusuniformity, choffset_x,
choffset_y, blu, flu, int_min, int_mean, int_stdev, int_max,
int_median, int_q87, nse_min, nse_mean, nse_stdev, nse_max, base,
tile_id) VALUES (%(id)s, %(nobj)s, %(focusmetric)s, %
(focusuniformity)s, %(choffset_x)s, %(choffset_y)s, %(blu)s, %(flu)s, %
(int_min)s, %(int_mean)s, %(int_stdev)s, %(int_max)s, %(int_median)s, %
(int_q87)s, %(nse_min)s, %(nse_mean)s, %(nse_stdev)s, %(nse_max)s, %
(base)s, %(tile_id)s)' {'int_q87': 6499.11498,
'focusuniformity': 95.1993894, 'nse_mean': 273.3298649998,
'int_stdev': 2763.36702, 'blu': 68.97684479995, 'nobj':
14597, 'flu': 68.2585204, 'int_min': -1874.16735,
'choffset_y': 0.0, 'choffset_x': 0.0, 'int_mean': 2965.79126, 'base':
'A', 'nse_stdev': 110.751434, 'int_median': 2022.095, 'nse_min': 0.0,
'nse_max': 732.833301, 'tile_id': 37504, 'int_max':
19389.40429998, 'id': 2L, 'focusmetric': 77.3844693}

The table is described as:

class RunBrowserImage(Base):
__tablename__ = runbrowser_image

id = Column(Integer,primary_key=True)
nobj = Column(Integer)
focusmetric = Column(Float)
focusuniformity = Column(Float)
choffset_x = Column(Float)
choffset_y = Column(Float)
blu = Column(Float)
flu = Column(Float)
int_min = Column(Float)
int_mean = Column(Float)
int_stdev = Column(Float)
int_max = Column(Float)
int_median = Column(Float)
int_q87 = Column(Float)
nse_min = Column(Float)
nse_mean = Column(Float)
nse_stdev = Column(Float)
nse_max = Column(Float)
base = Column(CHAR(1))
tile_id = Column(Integer,ForeignKey('runbrowser_tile.id'))

tile = relation(RunBrowserTile,backref=backref('images'))

I cannot figure out why the error.  I know it must be something
obvious, but I can't find it.

Any suggestions?

Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] getting all indexes in a metadata instance

2008-09-30 Thread Sean Davis

I am mirroring a database from mysql to postgresql.  Mysql allows
indexes to have the same names as columns.  I would like to find all
the indexes and rename them systematically to avoid these name
collisions.  How can I get the list of indexes and then modify the
names before creating the second schema in postgres from the metadata?

Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: getting all indexes in a metadata instance

2008-09-30 Thread Sean Davis



On Sep 30, 11:18 am, Sean Davis [EMAIL PROTECTED] wrote:
 I am mirroring a database from mysql to postgresql.  Mysql allows
 indexes to have the same names as columns.  I would like to find all
 the indexes and rename them systematically to avoid these name
 collisions.  How can I get the list of indexes and then modify the
 names before creating the second schema in postgres from the metadata?

Got it.  Loop over the tables and the indexes are in table.indexes.

Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Custom type definition and can't adapt 'INSERT INTO.... error

2008-09-27 Thread Sean Davis

I have been playing with new types using sqlalchemy and have an error
I do not understand.  Table schema and type definition are here:

-

def generate_uuid():
return uuid.uuid1()

class GUID(sa.types.TypeEngine):
def __init__(self):
pass

def get_col_spec(self):
return varchar(40)

def convert_bind_param(self, value, engine):
return str(value)

def convert_result_value(self, value, engine):
return uuid.UUID(value)

t_contacts = sa.Table('contacts',meta.metadata,
sa.Column('id',sa.types.Integer,primary_key=True),
sa.Column('uuid',GUID,default=generate_uuid),
sa.Column('firstname',sa.types.String(32),nullable=False),
sa.Column('lastname',sa.types.String(32),nullable=False),
sa.Column('email',sa.types.String(100),nullable=False),
sa.Column('phone',sa.types.String(32)))

--

In a Pylons web app, I get:

class 'sqlalchemy.exc.ProgrammingError': (ProgrammingError) can't
adapt 'INSERT INTO contacts (id, uuid, firstname, lastname, email,
phone) VALUES (%(id)s, %(uuid)s, %(firstname)s, %(lastname)s, %
(email)s, %(phone)s)' {'uuid':
UUID('58d6bcb4-8cc6-11dd-983d-0016cb972e45'), 'firstname': u'Sean',
'lastname': u'Davis', 'email': u'sdavis2 AT mail.nih.gov', 'phone':
u'301-435-2652', 'id': 3L}

What am I missing?

Thanks,
Sean


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Custom type definition and can't adapt 'INSERT INTO.... error

2008-09-27 Thread Sean Davis



On Sep 27, 5:16 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Sep 27, 2008, at 3:12 PM, Sean Davis wrote:





  I have been playing with new types using sqlalchemy and have an error
  I do not understand.  Table schema and type definition are here:

  -

  def generate_uuid():
     return uuid.uuid1()

  class GUID(sa.types.TypeEngine):
     def __init__(self):
         pass

     def get_col_spec(self):
         return varchar(40)

     def convert_bind_param(self, value, engine):
         return str(value)

     def convert_result_value(self, value, engine):
         return uuid.UUID(value)

  t_contacts = sa.Table('contacts',meta.metadata,
     sa.Column('id',sa.types.Integer,primary_key=True),
     sa.Column('uuid',GUID,default=generate_uuid),
     sa.Column('firstname',sa.types.String(32),nullable=False),
     sa.Column('lastname',sa.types.String(32),nullable=False),
     sa.Column('email',sa.types.String(100),nullable=False),
     sa.Column('phone',sa.types.String(32)))

  --

  In a Pylons web app, I get:

  class 'sqlalchemy.exc.ProgrammingError': (ProgrammingError) can't
  adapt 'INSERT INTO contacts (id, uuid, firstname, lastname, email,
  phone) VALUES (%(id)s, %(uuid)s, %(firstname)s, %(lastname)s, %
  (email)s, %(phone)s)' {'uuid':
  UUID('58d6bcb4-8cc6-11dd-983d-0016cb972e45'), 'firstname': u'Sean',
  'lastname': u'Davis', 'email': u'sdavis2 AT mail.nih.gov', 'phone':
  u'301-435-2652', 'id': 3L}

 assuming str(UUID()) returns a string, seems like your  
 convert_bind_param is not being called.   This method was deprecated  
 throughout 0.4 and is removed in 0.5, so if you're on 0.5 you should  
 use the bind_processor() and result_processor() methods described 
 athttp://www.sqlalchemy.org/docs/05/types.html

Thanks.  I had upgraded to 0.5 a while back and just came back to this
project and didn't make the connection that the types system had
changed.

Sean

 .
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Column metadata from mapped class

2008-07-22 Thread Sean Davis



On Jul 20, 11:28 am, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jul 20, 2008, at 7:48 AM, Sean Davis wrote:



  I have been playing with 0.5 and have a very simple question.  If I
  have a mapped class, User, how can I get at the columns of User?  I
  see lots of constructs like User.c, but User has no 'c' attribute
  now.  I am looking at finding the column types, names (to loop over),
  etc.

 theres a large section regarding this in the upgrade notes 
 athttp://www.sqlalchemy.org/trac/wiki/05Migration
 , though its focused on rationale .   The short answer for columns is  
 to use the Table (i.e. sometable.c.somecolumn, for col in  
 sometable.c:, etc).   If you want to get the table for a mapped class  
 if you don't have it already, say class_mapper(cls).mapped_table.

Thanks, and sorry I didn't look at that doc before asking.  That is
exactly what I needed.

Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Column metadata from mapped class

2008-07-20 Thread Sean Davis

I have been playing with 0.5 and have a very simple question.  If I
have a mapped class, User, how can I get at the columns of User?  I
see lots of constructs like User.c, but User has no 'c' attribute
now.  I am looking at finding the column types, names (to loop over),
etc.

Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Many-to-many back to single table

2007-10-12 Thread Sean Davis
I have two tables:

create table a (
id serial primary key,
name varchar(255) unique
);

create table b (
id serial primary key,
subject int references a(id),
object int references b(id),
otherinfo varchar(255)
);

I have been trying to pull ideas together from the self-referential portion
of the manual and the many-to-many mapping section, and I haven't figured
out how to go about coding this association table and referencing from table
a to get subjects and objects of a given member of a.  Is this possible to
do?

Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Multiple foreign keys to the same table from another table

2007-07-20 Thread Sean Davis

I have a table that has two columns that reference the same table in a
foreign-key relationship.  What do I need to specify and where to
avoid the error below?

class 'sqlalchemy.exceptions.ArgumentError': Error determining
primary and/or secondary join for relationship 'FeatureLoc.feature
(Feature)'. If the underlying error cannot be corrected, you should
specify the 'primaryjoin' (and 'secondaryjoin', if there is an
association table present) keyword arguments to the relation()
function (or for backrefs, by specifying the backref using the
backref() function with keyword arguments) to explicitly specify the
join conditions. Nested error is Can't determine join between
'featureloc' and 'feature'; tables have more than one foreign key
constraint relationship between them. Please specify the 'onclause' of
this join explicitly.

I am reflecting these tables from the database:

feature_t = Table('feature',metadata,autoload=True)
featureloc_t = Table('featureloc',metadata,autoload=True)

class Feature(object):
pass

class FeatureLoc(object):
pass

sqlalchemy.orm.mapper(Feature,feature_t,properties={
'elements' : relation(Element,backref='feature')
})
sqlalchemy.orm.mapper(FeatureLoc,featureloc_t,properties={
 'srcfeature' : relation(Feature),
 'feature': relation(Feature)
 })

Thanks,
Sean


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Multiple foreign keys to the same table from another table

2007-07-20 Thread Sean Davis



On Jul 20, 11:57 pm, Sean Davis [EMAIL PROTECTED] wrote:
 I have a table that has two columns that reference the same table in a
 foreign-key relationship.  What do I need to specify and where to
 avoid the error below?

 class 'sqlalchemy.exceptions.ArgumentError': Error determining
 primary and/or secondary join for relationship 'FeatureLoc.feature
 (Feature)'. If the underlying error cannot be corrected, you should
 specify the 'primaryjoin' (and 'secondaryjoin', if there is an
 association table present) keyword arguments to the relation()
 function (or for backrefs, by specifying the backref using the
 backref() function with keyword arguments) to explicitly specify the
 join conditions. Nested error is Can't determine join between
 'featureloc' and 'feature'; tables have more than one foreign key
 constraint relationship between them. Please specify the 'onclause' of
 this join explicitly.

 I am reflecting these tables from the database:

 feature_t = Table('feature',metadata,autoload=True)
 featureloc_t = Table('featureloc',metadata,autoload=True)

 class Feature(object):
 pass

 class FeatureLoc(object):
 pass

 sqlalchemy.orm.mapper(Feature,feature_t,properties={
 'elements' : relation(Element,backref='feature')
 })
 sqlalchemy.orm.mapper(FeatureLoc,featureloc_t,properties={
  'srcfeature' : relation(Feature),
  'feature': relation(Feature)
  })

Looks like this will do it:

sqlalchemy.orm.mapper(FeatureLoc,featureloc_t,properties={
 'srcfeature' :
relation(Feature,primaryjoin=featureloc_t.c.srcfeature_id==feature_t.c.id,backref='features'),
 'feature':
relation(Feature,primaryjoin=featureloc_t.c.feature_id==feature_t.c.id)
 })

Sorry for the noise.

Sean


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: save_or_update() with a unique but not primary key

2007-03-13 Thread Sean Davis

On Tuesday 13 March 2007 07:35, Sean Davis wrote:
 We are creating a database that will have a set of autoincrement primary
 keys on the tables.  However, many of the tables also have one or more
 unique keys associated with them.  Can we use save_or_update() (and, by
 extension, cascade='save_or_update', etc.) by specifying one of the unique
 keys rather than specifying the primary key directly?

Tried it.  Looks like not.  Sorry for the noise on the list.

Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Is it possible to know the size of a deferred PickleType?

2007-03-06 Thread Sean Davis

On Tuesday 06 March 2007 05:32, Sanjay wrote:
 Hi All,

 Wondering if it is possible to know the size of a file stored in a
 deferred column (PickleType), without retrieving the file itself.

I usually try to save the filesize as a separate column.

Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Tool to autogenerate code from db schema

2007-02-20 Thread Sean Davis
Just a quick question, but is there code available to autogenerate code for
SA or Elixir from an existing (rather large) database?  I could use SQLSoup
directly, but it really helps me to be able to see the generated code.
Also, some of the classes will benefit from some added methods.

Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Is there any way to call a python function for primary key generation

2007-02-13 Thread Sean Davis
On 2/13/07, vinjvinj [EMAIL PROTECTED] wrote:


 I use the mx.UID package to generate all my keys. Is there any way to
 specify that this function be called to generate the primary key for
 inserts?

 Thanks,


Could this not be done on the database side (depends on the RDBMS)?

Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] schema comments

2007-02-12 Thread Sean Davis
I looked over the docs but didn't find an answer (so the answer is probably
no).  Does SA allow descriptions (database comments) of tables and/or
columns?

Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Full Text Search using PostgreSQL and tsearch2

2007-01-18 Thread Sean Davis


On Thursday 18 January 2007 07:11, Sanjay wrote:

Hi All,

Trying to implement full text search with PostgreSQL and tsearch2,
being a beginner, I am facing some basic hurdles:

1. How to declare a table in SA, I mean, what SA datatype should
tsvector correspond to?
2. Can the index be defined using SA, or we need to do it in the
backend?
3. Can the trigger for auto update be defined using SA, or we need to
do it in the backend?
4. How to frame the query in SA?


SA doesn't support tsvectors, as far as I know.  The simplest thing in my mind 
is to build one table that contains the tsvector (and is not mapped to SA) 
and a key to the original record.  Then, you can do whatever queries you like 
(using the underlying database engine) to get keys to the data in the source 
table and use SA to grab these data.  Not ideal, but I think it will work.  
Alternatively, you can create a new type for SA; there is a recent message in 
the archives about doing that (not with tsvector, but).  As for querying, 
I'm not sure how that would be best implemented in SA.


Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Full Text Search using PostgreSQL and tsearch2

2007-01-18 Thread Sean Davis


On Thursday 18 January 2007 14:19, Chris Shenton wrote:

I'd be interested in how you work this out as I want to do something
similar.  Would you be willing to write it up and perhaps post it to
the wiki?

I was able to get MySQL's fulltext search working more quickly than
PostgreSQL's and that's what my customer is used to so that's what I'm
going to use for them.  I haven't yet gotten to integrate it with SA.

Down the road, I'd like to know how to do the same with PG.


See here for at least an overview

http://www.devx.com/opensource/Article/21674

There are other similar sites available via google.

Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Accessing DBAPI cursor object from connection

2007-01-18 Thread Sean Davis

I would like to access the underlying psycopg2 connection to get at a DBAPI2
cursor with the ultimate goal of using the copy_from/copy_to protocol for
moving large amounts of data to/from the database.  I can't seem to find a
way to do that from a db engine or connection object.  Is there a way
(assuming that I am using postgres)?

Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Accessing DBAPI cursor object from connection

2007-01-18 Thread Sean Davis


On Thursday 18 January 2007 17:42, Jonathan Ellis wrote:

engine.raw_connection().cursor()


Ah, yes!  Thanks.

Sean


On 1/18/07, Sean Davis [EMAIL PROTECTED] wrote:
 I would like to access the underlying psycopg2 connection to get at a
 DBAPI2 cursor with the ultimate goal of using the copy_from/copy_to
 protocol for moving large amounts of data to/from the database.  I can't
 seem to find a way to do that from a db engine or connection object.  Is
 there a way (assuming that I am using postgres)?

 Thanks,
 Sean




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Oracle autoload problem?

2007-01-09 Thread Sean Davis
I am experimenting with autoloading tables from Oracle (9.2) running on a
remote machine.  Normal selects using cx_Oracle work just fine.  Here is
what I get:

 from sqlalchemy import *
 eng = create_engine('oracle:// ...')
 md = BoundMetaData(eng)
 g2r = Table('gene2refseq',md,autoload=True)
Traceback (most recent call last):
  File stdin, line 1, in module
  File build/bdist.linux-x86_64/egg/sqlalchemy/schema.py, line 143, in
__call__
  File build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py, line 505,
in reflecttable
  File build/bdist.linux-x86_64/egg/sqlalchemy/databases/oracle.py, line
214, in reflecttable
  File build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py, line 255,
in execute
  File build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py, line 259,
in execute_text
  File build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py, line 329,
in _execute_raw
  File build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py, line 348,
in _execute
sqlalchemy.exceptions.SQLError: (DatabaseError) ORA-01008: not all variables
bound
 'select distinct OWNER from ALL_TAB_COLUMNS where TABLE_NAME = :table_name'
{'table_name': 'GENE2REFSEQ'}


Any thoughts?

Thanks,
Sean


--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---


[sqlalchemy] Re: Oracle autoload problem?

2007-01-09 Thread Sean Davis
On 1/9/07, Andrija Zarić [EMAIL PROTECTED] wrote:


 This very strange, because SQLAlchemy is issuing the query like it is
 supposed to do. There is bind variable (table_name) but for some
 reason cx_Oracle/Oracle is raising ORA-1008.

 Can you assert that following is working:
  import cx_Oracle as ora
  e = ora.connect('...')
  c = e.cursor()
  c.execute(select distinct OWNER from ALL_TAB_COLUMNS where
 TABLE_NAME = :table_name,{'table_name':'GENE2REFSEQ'})
  c.fetchall()


 I'm using autoload feature with Oracle 8.1.7 and 10XE, both tables
 with unique name and same name with multiple owners without any
 problems. SQLAlchemy is from svn trunk and cx_Oracle is 4.1


cx_Oracle indeed looks to be the issue.  I'll sort it out in more detail,
but bound parameters are not working for me in any queries I have tried.  It
works otherwise, but not with bind params.

Sean

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Lazy load a single column

2007-01-05 Thread Sean Davis

A simple question:

I have a table with one HUGE column.  Is there a way to make this column
lazy-loaded?

Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Lazy load a single column

2007-01-05 Thread Sean Davis

On 1/5/07, Lee McFadden [EMAIL PROTECTED] wrote:



On 1/5/07, Sean Davis [EMAIL PROTECTED] wrote:
 A simple question:

 I have a table with one HUGE column.  Is there a way to make this column
 lazy-loaded?



http://www.sqlalchemy.org/docs/adv_datamapping.myt#advdatamapping_properties_deferred



Perfect!  Thanks.

Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] SqlSoup error

2006-12-22 Thread Sean Davis


I have the following three tables and trying to do a join.  See below for 
details:


g_main (
  gene_id serial primary key,
  .
);

g_refseq (
  refseq varchar references refseq(refseq),
  gene_id int references g_main(gene_id)
);

refseq (
   refseq varchar primary key
);


from sqlalchemy.ext.sqlsoup import SqlSoup
db = SqlSoup('postgres://user:[EMAIL PROTECTED]/annodb4')
genes = db.g_main.select_by(symbol='ADAM12')
len(genes)

2

refseqs = db.g_refseq.select_by(gene_id=672)
len(refseqs)

13

join1 = db.join(db.g_main,db.g_refseq)

Traceback (most recent call last):
 File stdin, line 1, in module
 File build/bdist.linux-x86_64/egg/sqlalchemy/ext/sqlsoup.py, line 410, in 
join
 File build/bdist.linux-x86_64/egg/sqlalchemy/ext/sqlsoup.py, line 402, in 
map
 File build/bdist.linux-x86_64/egg/sqlalchemy/ext/sqlsoup.py, line 369, in 
class_for_table
 File build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py, line 19, in 
__init__
 File build/bdist.linux-x86_64/egg/sqlalchemy/orm/mapper.py, line 252, in 
compile
 File build/bdist.linux-x86_64/egg/sqlalchemy/orm/mapper.py, line 270, in 
_compile_all
 File build/bdist.linux-x86_64/egg/sqlalchemy/orm/mapper.py, line 497, in 
_initialize_properties

AttributeError: 'Mapper' object has no attribute '_Mapper__props'

I am using:

SQLAlchemy-0.3.3-py2.5.egg

Any suggestions on what I am missing?  


Thanks,
Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: SqlSoup error

2006-12-22 Thread Sean Davis


On Friday 22 December 2006 10:10, Alan Franzoni wrote:

 Any suggestions on what I am missing?

I don't use sqlsoup and I don't know whether you not using it correctly;
btw, if you're in hurry, as a simple workaround, I suggest you add this
line to sqlsoup.py, line 369, just above klass_query =... :

klass._mapper.compile()


and see if it works.


Alan,

This was, indeed, the fix.  And, to clarify for Michael, I did include a 
primary key on the g_refseq table but neglected to include it in the table 
def--sorry for being misleading.  

Thanks for the help.  


Sean

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Misunderstanding something with autoloading

2006-12-19 Thread Sean Davis

On Tuesday 19 December 2006 05:51, Alan Franzoni wrote:
   from sqlalchemy import *
   db = create_engine('postgres://user:[EMAIL PROTECTED]/test5')
   metadata = BoundMetaData(db)
   tb = Table('gffdata',metadata,autoload=True)

 This works fine on my system (ubuntu edgy, x86, python 2.5, postgresql
 8.1.4, psycopg 2.0.5, SA 0.3.3), could you please post the details of
 yours?

Thanks for trying it.  I am on openSUSE 10.2 x86_64, postgres 8.2 (running 
remotely on an Apple XServer), psycopy2.0.5.1, SA 0.3.3.  

I played a bit more and it happens only with a particular database.  When 
connecting to another database, it seems to work just fine.  I'll look into 
it more here, as it seems to be idiosyncratic.  If I come to any hard 
conclusions, I'll forward them along.  

Sean

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Misunderstanding something with autoloading

2006-12-18 Thread Sean Davis

I have a simple test case given here:

 from sqlalchemy import *
 db = create_engine('postgres://user:[EMAIL PROTECTED]/test5')
 metadata = BoundMetaData(db)
 tb = Table('gffdata',metadata,autoload=True)

Up to this point, I think this looks like what is in the tutorial.  However, I 
get the following error when trying to autoload.

Traceback (most recent call last):
  File stdin, line 1, in module
  File build/bdist.linux-x86_64/egg/sqlalchemy/schema.py, line 143, in 
__call__
  File build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py, line 505, in 
reflecttable
  File build/bdist.linux-x86_64/egg/sqlalchemy/databases/postgres.py, line 
386, in reflecttable
TypeError: __init__() takes at most 2 arguments (3 given)

 metadata.get_engine().raw_connection
bound method Engine.raw_connection of sqlalchemy.engine.base.Engine object 
at 0x9168d0

But after I do this call, I can autoload the table without problem.

 tb = Table('gffdata',metadata,autoload=True)

And selecting, etc., works fine at this point.  What am I missing?

Thanks,
Sean

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---