[sqlalchemy] newbie question: best way to factor and group data when only some columns change

2018-06-13 Thread Robert Henry
the results of the test run. Robert Henry -- 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. --

[sqlalchemy] flask-sqlalchemy - auto-complete in editor?

2017-05-27 Thread Robert M.
Hi, Is there anyway to get auto-complete for objects from flask-sqlalchemy ? It is extremely plainful to try to code using it without any auto-complete. Only think I could thing of was maybe use sqlalchemy instead and then at end of development s

Re: [sqlalchemy] Bulk Operations with Joined Table Inheritance

2017-01-25 Thread Robert Sami
On Wed, Jan 25, 2017 at 7:02 AM, mike bayer wrote: > > > On 01/24/2017 07:40 PM, Robert Sami wrote: > >> Thanks for the response Mike, >> >> I agree that using Core is pretty clean. One approach I considered was >> the following: >> >> ``` >>

Re: [sqlalchemy] Bulk Operations with Joined Table Inheritance

2017-01-24 Thread Robert Sami
r wrote: > > > On 01/24/2017 04:49 PM, Robert Sami wrote: > >> Hi SQLAlchemy wizards. >> >> I was interested in using the new bulk operations API >> (http://docs.sqlalchemy.org/en/latest/orm/persistence_techni >> ques.html#bulk-operations) >&

[sqlalchemy] Bulk Operations with Joined Table Inheritance

2017-01-24 Thread Robert Sami
Hi SQLAlchemy wizards. I was interested in using the new bulk operations API (http://docs.sqlalchemy.org/en/latest/orm/persistence_techniques.html#bulk-operations) but was looking for some advice based on my use case. I have a class “FooDerived” which corresponds to a table that is linked to

[sqlalchemy] Simple SQLAlchemy hiearchical inheritance model

2016-10-25 Thread Robert C
I am modeling a simple hierarchical database structure. My model is designed as follows: class ChatMessage(Base): __tablename__ = 'chat_message' sender_id = Column(Integer, ForeignKey('user.id'), primary_key=True) receiver_id = Column(Integer, ForeignKey('user.id'), primary_key=True)

Re: [sqlalchemy] setters and getters on an automapped table

2016-08-30 Thread Robert Minsk
ess='001122334455') > session.add(host) > session.commit() > > host = session.query(Host).one() > print host.mac_address > print host._mac_address > > if __name__ == '__main__': > main() > > > On Tue, Aug 30, 201

Re: [sqlalchemy] setters and getters on an automapped table

2016-08-29 Thread Robert Minsk
16 at 2:24 AM, Robert Minsk wrote: > > I am using automap_base to reflect a table. > > > > metadata = MetaData() > > metadata.reflect(bind=engine, only=['hosts']) > > automap = automap_base(metadata=metadata) > > automap.prepare() > > > > H

[sqlalchemy] setters and getters on an automapped table

2016-08-25 Thread Robert Minsk
I am using automap_base to reflect a table. metadata = MetaData() metadata.reflect(bind=engine, only=['hosts']) automap = automap_base(metadata=metadata) automap.prepare() Hosts = automap.classes.hosts The mac_address column in Hosts is binary and would like to to replace the mac_address with

Re: [sqlalchemy] accessing firebird on windows from linux

2016-05-17 Thread robert rottermann
ekey') # using sa engine = sa.create_engine('firebird+fdb://SYSDBA:thekey@10.42.0.150:3050/Users/elvis/Documents/VAS.fdb') in both cases the port is not needed, but can be used. robert On 17.05.2016 17:00, Mike Bayer wrote: firebird is very obscure / esoteric. I'd get a strai

[sqlalchemy] accessing firebird on windows from linux

2016-05-17 Thread robert rottermann
: engine = sa.create_engine('firebird+fdb://SYSDBA:thekey@10.42.1.150:3050///c:\\Users\\elvis\\Documents\\VAS.fdb') I tried many combinations of the part after the port. thanks for your hints robert -- You received this message because you are subscribed to the Google Groups "sq

[sqlalchemy] Re: `func.similarity` performance

2016-04-01 Thread Robert Smith
o_params(self, cursor, statement, > context=None): > TypeError: 'dict' object does not support indexing i tested a similar query with `regexp` and that works correctly, so I'm not sure what is different in this case. Regards On Thursday, March 31, 2016 at 9:46:34 PM UTC-6,

Re: [sqlalchemy] `func.similarity` performance

2016-04-01 Thread Robert Smith
trivial, it is better to look for alternatives. On Thursday, March 31, 2016 at 6:15:41 PM UTC-6, Mike Bayer wrote: > > > > On 03/31/2016 06:40 PM, Robert Smith wrote: > > Mike Bayer: > > > > Thank you for your response. I wasn't really asking whether the

Re: [sqlalchemy] `func.similarity` performance

2016-03-31 Thread Robert Smith
Jonathan Vanasco: Thank you. That's a good idea but in this case, I'm really wondering if sqlalchemy should use that small change to improve performance quite a bit in this type of queries. Otherwise, I think I would need to rely on raw SQL to perform a similarity operation and I'm not sure if

Re: [sqlalchemy] `func.similarity` performance

2016-03-31 Thread Robert Smith
;m pretty new to sqlalchemy, so I think I don't understand what you mean. Can you describe this a bit more? Regards On Thursday, March 31, 2016 at 7:43:11 AM UTC-6, Mike Bayer wrote: > > > > On 03/30/2016 09:50 PM, Robert Smith wrote: > > I'm using sqlalchemy 1.0.12 w

[sqlalchemy] `func.similarity` performance

2016-03-30 Thread Robert Smith
I'm using sqlalchemy 1.0.12 with postgreSQL 9.4.6 with the pg_trgm extension enabled. Basically, I'm performing a similarity-based query on a single column: In [26]: str(session.query(Model).order_by(desc(func.similarity(Model.description, 'string'))).limit(100)) Out[26]: 'SELECT model.id AS m

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: >

Re: [sqlalchemy] Determination of string lengths

2015-12-10 Thread &#x27;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 user

[sqlalchemy] sql works when run manually, not when part of sqlalchemy query

2015-11-24 Thread robert rottermann
ship`.accepted AS `tblMembership_accepted`, `tblMembership`.comment AS `tblMembership_comment`, `tblMembership`.bemerkungen AS `tblMembership_bemerkungen` \nFROM `tblMembership` \nWHERE `tblMembership`.`idPerson` = %s'] [parameters: (3L,)] thanks for any hints where to locate the problem rob

[sqlalchemy] Re: Authoring Dialects: How to Fix AssertionError: assert Decimal('15.7563') in [15.7563] ?

2015-05-14 Thread Robert Buck
The code is here: https://github.com/rbuck/sqlalchemy-nuodb Instructions (notably for pip dependencies) are documented in the README.rst file. The test is the SQL Alchemy compliance test suite. I am down to 12 or less failures now, so I am almost defect free. NumericTest_nuodb_pynuodb.test_re

[sqlalchemy] Authoring Dialects: How to Fix AssertionError: assert Decimal('15.7563') in [15.7563] ?

2015-05-14 Thread Robert Buck
I am authoring a dialect for our database technology and one of the tests is failing, but I am not quite sure why, or how to proceed. Would someone know where I'd look, or what I may be missing, to fix this aspect of the dialect? I am likely missing something, but I've already messed with the c

[sqlalchemy] idle in transaction using ZopeTransactionExtension with postgres

2015-02-26 Thread Robert Daniels
I'm using ZopeTransactionExtension (postgresql) as: DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))Base = declarative_base() When I invoke result = DBSession.execute("some sql query") The result comes back fine, however I notice when I review the server statu

[sqlalchemy] How to load sql file during unit test

2015-02-04 Thread Robert Daniels
I thought this would be easy to Google, but could not find anything. Using pyramid+sqlalchemy+postgres. I'm doing some unit tests and I have a large sql file that contains my db schema. The goal is to have the unit test create and populate the database with test data, run the tests, then remove

[sqlalchemy] MySQL's TRIM statement in sqlalchemy

2014-12-26 Thread Robert Buchholz
th an SQLa function? Cheers, Robert * The whole thing looks like this: SELECT * FROM categories c JOIN categories c2 ON c.slug = TRIM(TRAILING "-2" FROM c2.slug) WHERE c2.slug LIKE "%-2"; -- You received this message because you are subscribed to the Goo

Re: [sqlalchemy] Migrating databases: Alembic vs. Liquibase, Flyway, ??

2014-11-27 Thread Robert Grant
Yeah, bringing up Python as a "technology independence" problem seems bizarre. When supporting SQLAlchemy (The Database Toolkit for Python), it seems as though Python is a smaller problem than Java *and* XML. On Tuesday, 25 November 2014 05:07:24 UTC+2, Michael Bayer

Re: [sqlalchemy] How can I keep SQLAlchemy DB connection alive for always?

2014-10-14 Thread Robert Forkel
Pessimistic disconnect handling may be what you are looking for: http://docs.sqlalchemy.org/en/latest/core/pooling.html#disconnect-handling-pessimistic On Tue, Oct 14, 2014 at 9:27 PM, Eren Gölge wrote: > I a create a session with these following lines; > > > Base = declarative_base() > > engi

[sqlalchemy] query returns sqlalchemy.util._collections.KeyedTuple. not a maped class instance

2014-04-15 Thread robert
ult is of type: type(result) why? how can I use this element to update the database record? or, how can I get an updatable instance ? thanks very much robert -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from thi

[sqlalchemy] postgis samples problem (AttributeError: 'module' object has no attribute 'Function')

2014-04-05 Thread robert rottermann
n.Function): AttributeError: 'module' object has no attribute 'Function' how can I fix that ? thanks robert -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from i

Re: [sqlalchemy] Delete fails using automap with joined inheritance

2014-03-28 Thread Adrian Robert
Thank you sir, that resolved it, and in record time! On 2014.3.28, at 16:51, Michael Bayer wrote: > > On Mar 28, 2014, at 1:15 AM, Adrian Robert wrote: > >> I have been using the automap extension with postgres, with an inheritance >> structure using the joined i

[sqlalchemy] Delete fails using automap with joined inheritance

2014-03-27 Thread Adrian Robert
I have been using the automap extension with postgres, with an inheritance structure using the joined inheritance pattern. I could not figure out a way to have this reflected from the DB so I define the classes for this part of my schema explicitly, and when automap initializes, these classes g

Re: [sqlalchemy] SQLAlchemy 0.9.2 UnicodeEncodeErrors with PG 9.3.2 on Amazon RDS

2014-02-19 Thread Robert Forkel
FWIW I'm seeing not reproducible UnicodeEncodeErrors in my production systems, too. Alas only on ones with heavier load, and also with sqlalchemy 0.7.9. On Wed, Feb 19, 2014 at 3:45 PM, Michael Bayer wrote: > > On Feb 19, 2014, at 3:03 AM, Valentino Volonghi > wrote: > > > > >> 4. is this error

[sqlalchemy] problems with mysql reflect

2014-02-10 Thread robert rottermann
AL_DSN_A ="%(drivername)s://%(username)s@%(host)s/%(database)s?charset=utf8%(extra_param)s" % infoa local_engine_a = create_engine(LOCAL_DSN_A) BaseA.metadata.reflect(local_engine_a) thanks for your help and thanks for a wonderful library. robert -- You received this message b

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-06 Thread Adrian Robert
_9/orm/events.html#sqlalchemy.orm.events.MapperEvents.instrument_class > > > > On Feb 6, 2014, at 4:32 AM, Adrian Robert wrote: > >> One other point, I was trying out the dogpile cache example and ran into >> (after I stuck a ".encode('utf-8')" into the key

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-06 Thread Adrian Robert
iled This was fixed by a hack sqlalchemy.ext.automap.__dict__[cls.__name__] = cls run over all the automap-created classes. It might be I'm only having to do this because I'm doing something wrong elsewhere, but I just thought I'd mention it in case it comes up for someone.

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-02 Thread Adrian Robert
Thanks, that works beautifully. I had noticed name_for_scalar_relationship parameter but I guess wasn't confident enough that I understood what was going on to try it. :-[ -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this

[sqlalchemy] Automap and naming of relationship attributes

2014-02-01 Thread Adrian Robert
Hi, I'm new to sqlalchemy though I've used other ORMs (e.g. Hibernate) before, and I'm trying to use the new automap feature. However it seems to be using the foreign table name rather than a suffixed version of the column name when naming relationships. Is there a reason for doing it this wa

Re: [sqlalchemy] group_by and lazy=False relationship problem

2014-02-01 Thread Robert Tasarz
On 01/31/2014 10:56 PM, Michael Bayer wrote: > On Jan 31, 2014, at 2:49 PM, Robert Tasarz wrote: >> Hi, >> >> I'm almost sure this is a bug, but maybe I'm missing something obvious. >> I've tested it with Python 3.3, SQLAlchemy 0.9.1, PostgreSQL 9.3

[sqlalchemy] group_by and lazy=False relationship problem

2014-01-31 Thread Robert Tasarz
m(i.value) AS sum1 FROM p LEFT OUTER JOIN i ON p.id = i._elem GROUP BY p.id ORDER BY sum1 LIMIT %(param_1)s) AS anon_1 LEFT OUTER JOIN a AS a_1 ON anon_1.p_id = a_1._elem ORDER BY anon_1.sum1' So is it bug or some limitation? Any idea how to workaround it? regards, Rob

Re: [sqlalchemy] Build Query Without Objects

2014-01-14 Thread Robert Forkel
guess this could help: http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#selecting best robert On Tue, Jan 14, 2014 at 4:11 PM, Alex Meadows wrote: > Greetings, > > I've been reading through the docs and am still very new to SQLAlchemy but > haven't found an ans

Re: [sqlalchemy] Can sqlalchemy help me solve this contraint issue?

2013-12-18 Thread Robert Betts
Hi Michael Thank you, this is what I assumed! Rob On 18 Dec 2013, at 16:25, Michael Bayer wrote: > > On Dec 18, 2013, at 8:36 AM, Robert Betts > wrote: > >> Jonathan, Michael >> >> Ignoring the debate on overloading a table to cater for multiple &g

Re: [sqlalchemy] Can sqlalchemy help me solve this contraint issue?

2013-12-18 Thread Robert Betts
Jonathan, Michael Ignoring the debate on overloading a table to cater for multiple relationships, I think we are nearly back we we started i.e. a table where we would like to add an either or constraint. Other than database triggers or (before_flush, before_commit), is the a declarative SQLAl

Re: [sqlalchemy] Re: Functions sometimes return decimal or float

2013-12-06 Thread Robert Buchholz
des SUM, there's still AVG and other mathematical functions, that you can still use and not be aware of the impact in other DB engines. My goal was to make it harder to make a mistake unknowingly. Cheers, Robert -- You received this message because you are subscribed to the Googl

[sqlalchemy] Functions sometimes return decimal or float

2013-12-06 Thread Robert Buchholz
ow do you deal with this situation? Cheers, Robert -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to t

Re: [sqlalchemy] query results are not converted to specialized class with joined table inheritance

2013-07-26 Thread Robert Forkel
my bad, i switched from using orm to raw insert statements for initial population of one table of my database and forgot to insert a value for the discriminator. thanks for the hint. best robert On Fri, Jul 26, 2013 at 5:50 PM, Michael Bayer wrote: > use echo="debug", then look

[sqlalchemy] query results are not converted to specialized class with joined table inheritance

2013-07-26 Thread Robert Forkel
class, although the sql query seems to be created correctly, i.e. including a "LEFT OUTER JOIN" clause. I don't really know how to go on with debugging, so all I did so far was comparing this particular case with others in my app where it works - without spotting any problems

Re: [sqlalchemy] Related object not updating on flush, only on commit

2013-06-13 Thread Robert Buchholz
ate' on the relation does not seem to be easily accessible through a parameter, although I'm certain it's possible hooking into the right event. For now, I'll go with a scoped version of your recipe. Thanks a lot! Robert -- You received this message because you are subscribed

[sqlalchemy] Related object not updating on flush, only on commit

2013-06-12 Thread Robert Buchholz
ments / expectations inline. I was not able to find documentation, a bug or mailing list thread. Maybe I missed something obvious? Cheers Robert -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiv

[sqlalchemy] Try out our data modeller for SQLAlchemy

2013-03-29 Thread Robert Betts
Hey there, we have made our modeller available for general use.Take a look http://bit.ly/11WKfx9. It is a graphical relational modelling tool, it also generates SQL syntax for MySQL and SQLite, Python code for SQLAlchemy. -- You received this message because you are subscribed to the Google

[sqlalchemy] how to use ForeignKeyConstraint ?

2013-02-24 Thread robert rottermann
d', u'tblFlag_id'), {} ) However, if I do so, I get an sqlalchemy.exc.NoForeignKeysError: Could not determine join condition between parent/child error how should I use ForeignKeyConstraint correctly? thanks robert ## -

Re: [sqlalchemy] using an unmapped object to get the mapped object from a session

2013-01-11 Thread Robert Forkel
Transient Am 11.01.2013 22:33 schrieb "Chris Withers" : > On 11/01/2013 20:01, Michael Bayer wrote: > >> >> On Jan 11, 2013, at 1:37 PM, Chris Withers wrote: >> >> On 11/01/2013 15:26, Michael Bayer wrote: >>> what is it looking up ?what's a "myobj" ? >> > > An unmappe

Re: [sqlalchemy] Storing a two dimensional list structure with different item types in Postgres 9.1

2012-12-20 Thread Robert Forkel
If you are only after storage (leaving aside querying, indexing, ...) a simple JSON column [1] could do. The advantage being portability between databases. I've used this to as simple key-value store of data associated with a row. regards robert [1] http://docs.sqlalchemy.org/en/rel_0_8

Re: [sqlalchemy] Creating a feed related to different object type

2012-11-27 Thread Robert Forkel
asier when using pyramid, because you already have a component registry available). So with this technology you'd register the same FeedItem class as adapter for the various sqlalchemy models, which means that at adaption time, the object to adapt will be passed to you. regards robert

Re: [sqlalchemy] Comparing Hybrid Property to Boolean results in sub-optimal SQL query

2012-11-26 Thread robert
On Monday, November 26, 2012 5:39:47 PM UTC-8, Michael Bayer wrote: > > > On Nov 26, 2012, at 8:25 PM, robert wrote: > > Hello, > > Consider the following class and its hybrid property: > > class Interval(Base): >> __tablename__ = 'interval' &

[sqlalchemy] Comparing Hybrid Property to Boolean results in sub-optimal SQL query

2012-11-26 Thread robert
Hello, Consider the following class and its hybrid property: class Interval(Base): > __tablename__ = 'interval' > id = Column(Integer, primary_key=True) > start = Column(Integer, nullable=False) > end = Column(Integer, nullable=False) @hybrid_property > def contains_on

Re: [sqlalchemy] Inheriting a functionality in SQLA

2012-11-20 Thread Robert Forkel
As far as i know each declarative Base has its own metadata registry. You are using two. Why not use multiple mixins to inherit the columns? Am 20.11.2012 10:31 schrieb "AlexVhr" : > I'm trying to incapsulate some functionality (some columns mainly) into > base classes to inherit my models from t

Re: [sqlalchemy] Audit Table / History Table

2012-11-19 Thread Robert Forkel
http://docs.sqlalchemy.org/en/rel_0_8/orm/examples.html#versioned-objects looks like what you may want. On Mon, Nov 19, 2012 at 9:10 PM, LPG wrote: > I'm looking for details on implementing an audit table, either through sqla > itself or in a way that plays nicely with sqla. It looks like there u

Re: [sqlalchemy] Documenting sqlalchemy objects via sphinx automodule

2012-09-04 Thread Robert Forkel
I've been hitting the same wall, and decided that autoload was the wrong way to go. Once you want to generate documentation for a database from the models, you typically do not want allow frequent changes of the DB structure anymore. So at this point, I just wrote a script to create basic model cla

Re: [sqlalchemy] __main__ error

2012-08-29 Thread Robert Forkel
7;, .. whatever else there is in geojson ...]]) On Wed, Aug 29, 2012 at 1:34 PM, Gery . wrote: > > > That was really helpful Robert, it works nicely, how could I modify this > code to get geojson format? is it possible in this way

Re: [sqlalchemy] __main__ error

2012-08-29 Thread Robert Forkel
for borehole in alldata: for attr in sorted(filter(lambda a: not a.startswith('_'), dir(borehole))): print attr, getattr(borehole, attr) could do the trick On Wed, Aug 29, 2012 at 1:24 PM, Gery . wrote: > > thanks Robert, using your suggestion I get: > > [&#x

Re: [sqlalchemy] __main__ error

2012-08-29 Thread Robert Forkel
doesn't look like an error to me. It's just the result of your print alldata call. It depends on Postgis which attributes are available on the Borehole instances, but you could use print dir(alldata[0]) to get an idea about what is available. On Wed, Aug 29, 2012 at 12:37 PM, Gery . wrote: >

Re: [sqlalchemy] mapping postgres sequences?

2012-05-29 Thread Robert Forkel
example now includes your second question: from sqlalchemy import Sequence, create_engine, MetaData, Column, Integer from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Model(Base): __tablename__ = 'model' col = Column(Integer, Sequence('seq'), prima

Re: [sqlalchemy] mapping postgres sequences?

2012-05-29 Thread Robert Forkel
working example for the first question: from sqlalchemy import Sequence, create_engine, MetaData if __name__ == "__main__": md = MetaData() e = create_engine('postgresql://rforkel@/test1', echo=True) md.bind = e s = Sequence('name', metadata=md) md.create_all() print list(

Re: [sqlalchemy] mapping postgres sequences?

2012-05-29 Thread Robert Forkel
ad 1) from http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#defining-sequences : The Sequence object also has the ability to be executed standalone like a SQL expression, which has the effect of calling its “next value” function: seq = Sequence('some_sequence') nextid = connection.execute(s

Re: [sqlalchemy] How to get DDL string from metadata?

2012-04-24 Thread Robert Forkel
[1] > http://docs.sqlalchemy.org/en/latest/core/engines.html#sqlalchemy.create_engine > > > On 24.4.2012, at 9:50, Robert Forkel wrote: > >> what I do is using a custom engine like this: >> >> >>        out = StringIO() >>        def dump(sql, *mu

Re: [sqlalchemy] How to get DDL string from metadata?

2012-04-24 Thread Robert Forkel
write(('%s' % sql.compile(dialect=engine.dialect)).strip()+';\n/\n') engine = create_engine('oracle://', strategy='mock', executor=dump) regards robert On Tue, Apr 24, 2012 at 9:33 AM, Stefan Urbanek wrote: > Hi, > > How can I get a string that is

[sqlalchemy] ForeignKeyConstraint with composite keys doesn't throw appropriate exception with multiple tables

2012-04-02 Thread Robert Rollins
While I was writing up a many-to-many relationship between tables where one has a composite primary key, I ran into problems that initially prompted me to start writing this post. Here's my original code that was giving the confusing error about which I originally began writing: class AccountSync

[sqlalchemy] Re: Easy way to read/write columns from an Association Object that's hidden inside an Association Proxy?

2012-03-26 Thread Robert Rollins
have thought of doing it like that. On Mar 23, 5:47 pm, Michael Bayer wrote: > On Mar 23, 2012, at 8:33 PM, Robert Rollins wrote: > > > > > I access the list of contacts which have been synced to a certain > > account by using Account.synced_contacts.  However, I now realiz

[sqlalchemy] Easy way to read/write columns from an Association Object that's hidden inside an Association Proxy?

2012-03-23 Thread Robert Rollins
I'm writing a contact management system that gathers data from various canonical sources, collates it, then sends it to various MailChimp accounts so that their owners can send emails to our contact lists using MailChimp's services. I need to keep track of contacts who've unsubscribed from these e

Re: [sqlalchemy] trouble to define a "cascading" m:n relationship

2012-03-18 Thread robert rottermann
["tblServiceTechnologyCompetence"] technologies = relationship( "tblServiceTechnology", secondary=tblServiceTechnology_has_Competence.__table__, backref = 'competences' ) On 17/03/12 09:46, robert rottermann wrote: hi there, I have a proble defin

[sqlalchemy] trouble to define a "cascading" m:n relationship

2012-03-17 Thread robert rottermann
e error I get is: AttributeError: 'tblServiceTechnology_has_Competence' object has no attribute 'c' how should I define such a relationship. thanks for your time robert -- You received this message because you are subscribed to the Google Groups "sqlalchemy"

Re: [sqlalchemy] how to use substring in the where clause?

2012-03-08 Thread Robert Forkel
t func > and > from sqlalchemy import func > > the second import is what I found out while experimenting with the query and > after I saw your reply, I tried your code and both works the same. > > > > > On 08-03-2012 12:39, Robert Forkel wrote: >> >> sq

Re: [sqlalchemy] how to use substring in the where clause?

2012-03-08 Thread Robert Forkel
sqlalchemy.sql.expression.func may work for this: from sqlalchemy.sql.expression import func ... q_doc.filter(func.substring(model.Doc.FileNameStr, 22, 1)==search_str) ... 2012/3/8 Timuçin Kızılay : > I have a query contains SUBSTRING in where clause: > > Select top 100 * from _Doc > where SUBST

[sqlalchemy] CREATE SEQUENCE issued twice (sqlalchemy 0.7.4 with oracle)

2012-01-23 Thread Robert Forkel
Y (pk) ) CREATE SEQUENCE schemaname.testtable_pk_seq Is this a bug? regards robert -- 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

Re: [sqlalchemy] SqlAlchemy dynamic query generation

2011-12-22 Thread Robert Forkel
ns)).all() might do the trick (untested). On Thu, Dec 22, 2011 at 9:53 AM, Sana klh wrote: > Hi Robert Forkel, > > You got it right i am trying to have a combination of expression combined in > and_. > > I need to add the attribute only when it is not equal to null.So i tried to > c

Re: [sqlalchemy] SqlAlchemy dynamic query generation

2011-12-21 Thread robert rottermann
the string you are generating must be proper sql. to test is you migth print it and try in directly against the db. but what you show us is for sure no valid sql. In sql the equality operator is not '==' but '='. robert On 22/12/11 06:34, Sana klh wrote: I am getting

Re: [sqlalchemy] SqlAlchemy dynamic query generation

2011-12-21 Thread Robert Forkel
You may want to look at the tutorial [1]. In the code you pasted you are assembling a string to pass to filter. While you can do that (but then it should be proper sql not python!), what you want to do is passing a python expression like db.User.age==age, or a combination of expressions combined us

[sqlalchemy] bug in reflection.py sqla 0.7.3

2011-11-30 Thread Robert Forkel
ordered_tnames.index(ref_pos, tname) tnames = ordered_tnames return tnames best regards robert -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googleg

Re: [sqlalchemy] Column Mixin

2011-11-27 Thread Robert Forkel
Hi, I'm doing something similar and ended up giving all columns contributed by a mixin a common prefix, and have the copy method loop over all columns of an object, picking out the right ones. Regards Robert Am 26.11.2011 15:26 schrieb "Mark Erbaugh" : > I'm using a Colum

Re: [sqlalchemy] Re: howto Sqlalchemy atomic transaction ??

2011-11-21 Thread Robert Forkel
DBSession.flush() after the DBSession.add call might be enough. On Mon, Nov 21, 2011 at 12:48 PM, sajuptpm wrote: > Model > > class VDCTemplates(DeclarativeBase): >    __tablename__='cd_vdc_templates' >    id = Column(Unicode(50), primary_key=True) >    vdc_id=Column(Unicode(50), Forei

Re: [sqlalchemy] exists for query

2011-11-18 Thread Robert Forkel
query.first() may do the trick. Regards Robert Am 18.11.2011 15:25 schrieb "lestat" : > > I often pass db query in template context, and in template I check if > it exists, that render one html block, else other html block. > > Can I in sqlalchemy check existance of que

Re: [sqlalchemy] Determine column properties created via declarative mixins

2011-10-17 Thread Robert Forkel
ages/sqlalchemy/orm/properties.py", line 724, in __str__ return str(self.parent.class_.__name__) + "." + self.key AttributeError: 'RelationshipProperty' object has no attribute 'parent' >>> import sqlalchemy >>> sqlalchemy.__version__ '0

[sqlalchemy] Determine column properties created via declarative mixins

2011-10-17 Thread Robert Forkel
type sqlalchemy.schema.Column, but this doesn't give foreign keys declared via @declared_attr) best regards robert -- 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

Re: [sqlalchemy] Many-to-One relationship where each side has different typed keys?

2011-09-16 Thread Robert Rollins
You're a lifesaver! That method works perfectly for me. Since the Oracle side is read-only, I didn't need to use the StringAsInt class, but the rest of it worked like a charm. I look forward to the eventual resolution of that ticket, as this process really is quite convoluted. -- You receiv

[sqlalchemy] Many-to-One relationship where each side has different typed keys?

2011-09-16 Thread Robert Rollins
I have a table of survey responces which each correspond to a particular student, identified by an integer student_id. The database which stores that student's data, however, has their id in a VARCHAR2 column. The data in that column is really just an int, but I can't change the Oracle database

[sqlalchemy] Postgres: autoincremet sequence do not work after upgrade to sql 7.2

2011-09-03 Thread robert rottermann
box this works well (postgres 8.4). However on the live database (which is postgres 7.x) I get the error mentioned above. Is there some flag I can set, so sa behaves as it did before? thanks robert -- You received this message because you are subscribed to the Google Groups "sqlalchemy"

[sqlalchemy] Re: cascade_backrefs=False broken for many-to-many relationships?

2011-06-24 Thread Robert Rollins
the wrong direction. Using "backref=backref('users', cascade_backrefs=False)" has fixed my problem. Thanks for the quick response! On Jun 23, 4:34 pm, Michael Bayer wrote: > On Jun 23, 2011, at 7:12 PM, Robert Rollins wrote: > > > > > I'm usi

[sqlalchemy] cascade_backrefs=False broken for many-to-many relationships?

2011-06-23 Thread Robert Rollins
I'm using SQLAlchemy 0.7.1 on a MySQL 5.1.57 database, and I'm getting unexpected behavior with the cascade_backrefs=False parameter for my many-to-many relationships. Here's the pertinent table code: Base = declarative_base() class ZKGroup(Base): __tablename__ = 'groups' id = C

[sqlalchemy] question re using the session object

2011-06-14 Thread robert rottermann
need it. Now my question: is it ok to use this single instance troughout the life of the Zope severer, or should I call Session() whenever I need a session? thanks robert -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to

Re: [sqlalchemy] SystemError: null argument to internal routine

2011-03-11 Thread robert rottermann
this was caused by some error erlier error that somehow messed up the test environment. thanks for listening robert Am 11.03.2011 10:23, schrieb robert rottermann: Hi there, when testing one of my routines I get a strange error. SystemError: null argument to internal routine this is the

[sqlalchemy] SystemError: null argument to internal routine

2011-03-11 Thread robert rottermann
session = self.getSession() s = doctypCL.__table__.select()#[doctyp.c.typid,doctyp.c.doctyp,doctyp.c.subtyp,doctyp.c.topleveldir]) records = session.execute(s) I am using sqlalchemy 0.6.6 The DB is Postgress thanks for pointers where to fix this error robert Error in test testAddNe

[sqlalchemy] Re: condition on every query

2011-02-20 Thread robert
On Feb 20, 8:59 pm, Michael Bayer wrote: > the cleanest and most foolproof way is to join on relationships that have the > condition: > > related_non_deleted = relationship(Related, > primaryjoin=and_(Related.deleted==False, Related.foo_id==id), viewonly=True) I agree that the explicit approach

[sqlalchemy] condition on every query

2011-02-20 Thread robert
I'm looking for a way to add a condition to every query, including child queries. I've tried both the Pre-Filtering Query (http:// www.sqlalchemy.org/trac/wiki/UsageRecipes/PreFilteredQuery) and the Global Query Filter (http://www.sqlalchemy.org/trac/wiki/UsageRecipes/ GlobalFilter) recipes from t

[sqlalchemy] get_col_spec behavior has changed from 0.5.8 to 0.6.X

2010-08-13 Thread robert rottermann
' object has no attribute 'get_col_spec' it seems to work still with MySQL but not with postgres. (maybe MySQL uses a slightly older version out of the 6.xx serie) what is the "correct" way to build a list of fields a table provides ? thanks robert -- You received this message

Re: [sqlalchemy] Declarative syntax with column_property (v0.6.3)

2010-08-03 Thread Robert Sudwarts
Please see my comments below. Regards, Rob On 3 August 2010 14:05, Michael Bayer wrote: > > On Aug 3, 2010, at 7:47 AM, Robert Sudwarts wrote: > > Hi Michael, > > I'm guilty of two over-simplifications in the code used in my example... > > Firstly, the substring

Re: [sqlalchemy] Declarative syntax with column_property (v0.6.3)

2010-08-03 Thread Robert Sudwarts
keymap = metadata._keymap 2367 processors = metadata._processors 2368 if self._echo: AttributeError: 'NoneType' object has no attribute '_keymap' On 2 August 2010 19:42, Michael Bayer wrote: > > On Aug 2, 2010, at 1:40 PM, Michael Ba

[sqlalchemy] Declarative syntax with column_property (v0.6.3)

2010-08-02 Thread Robert Sudwarts
Hi, I'm having trouble understanding the correct syntax to be used with Declarative and a column property. The select statement I'm using is: select([func.substr(my_table.c.my_string, 2, 3)]).label(my_substr'), deferred=True And (as per the docs using the expanded syntax, this works as expected.

[sqlalchemy] how to use primary/secondary join when there are no foreign keys

2010-07-29 Thread robert rottermann
ta.`ID_cis` = cisbr.`ID_cisbr`', on relationship Branchen.branche. Do the columns in 'foreign_keys' represent only the 'foreign' columns in this join condition ? when I use the following setup: I would be very glad, if somebody could tell me, what I am doing wrong. thanks

[sqlalchemy] error:Could not determine relationship direction for primaryjoin condition

2010-07-29 Thread robert rottermann
when I use the following setup: I would be very glad, if somebody could tell me, what I am doing wrong. thanks robert this is the select that I want to implement: """ select * from cisdata c, cisbr cb branchen b, where c.ID_cis = cb.ID_cisbr and cb.ID_br = b.I

Re: [sqlalchemy] Classmethods with Session and Declarative Syntax

2010-06-16 Thread Robert Sudwarts
Goddit !! Thank you so much!! On 16 June 2010 14:33, Michael Bayer wrote: > > On Jun 16, 2010, at 7:58 AM, Robert Sudwarts wrote: > > Hi, > > I'm having difficulty understanding how to call/create a session to access > a "class method" of a declaratively

[sqlalchemy] Classmethods with Session and Declarative Syntax

2010-06-16 Thread Robert Sudwarts
Hi, I'm having difficulty understanding how to call/create a session to access a "class method" of a declaratively defined table/object: essentially my understanding of how session works in this context is at fault... Clearly, the @classmethod requires a **session** (and I realise that: "declarat

  1   2   >