Re: [sqlalchemy] full outer join?

2015-04-17 Thread Stefan Urbanek
I've added a PR for full=True in outerjoin(), join() and Join(): https://github.com/zzzeek/sqlalchemy/pull/167 FULL OUTER JOIN, besides other uses, is very useful in ETLs for doing transformations on top of table differences. Using two outer joins, as suggested in one of the above posts, un

Re: [sqlalchemy] Referencing DELETE table from nested statement

2014-12-03 Thread Stefan Urbanek
C-5, Michael Bayer wrote: > > why don’t you use a NOT EXISTS correlated subquery? that way the subquery > can refer to the outer table completely, rather than having just one column > where you can call IN. > > > > > On Dec 3, 2014, at 12:36 PM, Stefan Urbanek > wrot

[sqlalchemy] Referencing DELETE table from nested statement

2014-12-03 Thread Stefan Urbanek
Hi, How can I reference a table that I am deleting from in an inner/nested statement? Here is my simplified oritinal version, no inner condition: rownum = sql.expression.over(sql.func.row_number(), partition_by=table.c.some_id,

[sqlalchemy] Relative month in date arithmetic

2014-12-01 Thread Stefan Urbanek
Hi, How can I specify relative date on a column where the component is a month? Something like "date_column - interval '3 months'" The python `timedelta()` does not contain the month component. Cheers, Stefan -- You received this message because you are subscribed to the Google Groups "sqla

[sqlalchemy] Re: Passing a dict as JSON argument to a custom Postgres function

2014-08-22 Thread Stefan Urbanek
custom function? On Friday, August 22, 2014 11:50:01 AM UTC-4, Stefan Urbanek wrote: > > Hi, > > I have a custom PostgreSQL function that takes two JSON-type arguments: > > CREATE OR REPLACE FUNCTION "update_json"(original json, update_obj json) > > > When I

[sqlalchemy] Passing a dict as JSON argument to a custom Postgres function

2014-08-22 Thread Stefan Urbanek
Hi, I have a custom PostgreSQL function that takes two JSON-type arguments: CREATE OR REPLACE FUNCTION "update_json"(original json, update_obj json) When I try to use the function in sqlalchemy: a_dictionary = dict(...) value = sqlalchemy.sql.func.update_json(a_json_column, a_dictionary) ta

Re: [sqlalchemy] Unable to multi-insert records with SQL functions

2014-06-04 Thread Stefan Urbanek
sense. if you just put it in the first element that will work also: > > > data = [ > {"id": 1, "value": "foo", "adate":sql.func.now()}, > {"id": 2, "value": "bar"} > ] > > stmt = table.insert(

[sqlalchemy] Re: Unable to multi-insert records with SQL functions

2014-06-03 Thread Stefan Urbanek
3, 2014 5:40:38 PM UTC-4, Stefan Urbanek wrote: > > Hi, > > I'm trying to multi-insert records which contain a function: > > record = { > > "some_date": sql.func.now() > > key: value, ... > > } > > > When I execute table insert

[sqlalchemy] Re: Unable to multi-insert records with SQL functions

2014-06-03 Thread Stefan Urbanek
Postgres. On Tuesday, June 3, 2014 5:44:16 PM UTC-4, Jonathan Vanasco wrote: > > Which database are you using? > -- 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 s

[sqlalchemy] Unable to multi-insert records with SQL functions

2014-06-03 Thread Stefan Urbanek
Hi, I'm trying to multi-insert records which contain a function: record = { "some_date": sql.func.now() key: value, ... } When I execute table insert with list of records where len(records) > 1 then I get an error: “sqlalchemy.exc.ProgrammingError: (ProgrammingError) can't adapt

[sqlalchemy] Cubes OLAP 1.0alpha with new SQL backend features

2014-01-07 Thread Stefan Urbanek
Hi, First, happy new year to you all and thanks for the great work on SQLAlchemy. I just would like to share a bit of news. Cubes – Python Lightweight OLAP framework is approaching 1.0 with quite a few new things. Cubes is using SQLAlchemy for the SQL ROLAP backend. The notable SQL related cha

Re: [sqlalchemy] How to get server or dialect version or properties?

2013-04-13 Thread Stefan Urbanek
Thank you, this solves my problem. On Saturday, April 13, 2013 2:53:15 PM UTC-5, Michael Bayer wrote: > > there should be engine.dialect.server_version_info available, once at > least one connection has been made. > > > > > On Apr 13, 2013, at 12:26 PM, Stefan Urban

[sqlalchemy] How to get server or dialect version or properties?

2013-04-13 Thread Stefan Urbanek
Hi, In Cubes I would like to optionally use the upcoming CREATE MATERIALIZED VIEW [1] feature in Postgres 9.3 (or any other database that supports it). There will be plain alternative "CREATE TABLE" for Postgres < 9.3. [1] http://michael.otacoo.com/postgresql-2/postgres-9-3-feature-highlight-m

Re: [sqlalchemy] Problem with inserting multiple rows as lists/tuples

2012-12-27 Thread Stefan Urbanek
On 27.12.2012, at 23:21, Michael Bayer wrote: > > > On Dec 27, 2012, at 4:55 PM, Stefan Urbanek wrote: > >> Hi, >> >> I am trying to pass multiple rows as tuples into an INSERT statement.: >> >> # buffer is list of lists/tuples, like: [ [

[sqlalchemy] Problem with inserting multiple rows as lists/tuples

2012-12-27 Thread Stefan Urbanek
Hi, I am trying to pass multiple rows as tuples into an INSERT statement.: *# buffer is list of lists/tuples, like: [ [1, "foo"], [2, "bar"], ... ] * insert = self.table.insert() engine.execute(insert, buffer) This fails with: File "/opt/local/Library/Frameworks/Python.framework/Ve

Re: [sqlalchemy] How to quote table and schema without Table object?

2012-10-22 Thread Stefan Urbanek
AM UTC-5, Michael Bayer wrote: > > there's the quote() method which doesn't expect any schema object, just > the name and a flag "force" which you can leave as None to have it > determine quoting automatically. > > On Oct 22, 2012, at 12:58 AM, Stefan Urbanek

[sqlalchemy] How to quote table and schema without Table object?

2012-10-21 Thread Stefan Urbanek
Hi, I am creating some custom compiled constructions and I need to create properly quoted schema and table, however I have both only as strings because the table does not exist yet (for example: CREATE TABLE ... AS SELECT ...). It looks like all table quote_* methods in IdentifierPreparer expe

Re: [sqlalchemy] How to drop a view which is represented by Table instance?

2012-05-07 Thread Stefan Urbanek
On 8.5.2012, at 0:18, Michael Bayer wrote: > > On May 7, 2012, at 6:09 PM, Stefan Urbanek wrote: > >> >> p.s.: On the other hand, Table.is_view might be a good flag - to maintain >> consistency with the fact that Table() can reflect a view. However, I am not >

Re: [sqlalchemy] How to drop a view which is represented by Table instance?

2012-05-07 Thread Stefan Urbanek
On 7.5.2012, at 20:27, Michael Bayer wrote: > > On May 7, 2012, at 2:03 PM, Stefan Urbanek wrote: > >> Thanks, this is partially helpful. However, in the example there is: >> >> stuff_view = view("stuff_view"... >> >> and not: >> >

Re: [sqlalchemy] How to drop a view which is represented by Table instance?

2012-05-07 Thread Stefan Urbanek
e compilation of > sqlalchemy.schema.DropTable which would somehow have to check those Table > objects you have which are actually views, maybe if you put a flag on them > table.isview=True or something like that. > > > > On May 6, 2012, at 7:07 AM, Stefan Urbanek wrote:

[sqlalchemy] How to drop a view which is represented by Table instance?

2012-05-06 Thread Stefan Urbanek
using SQLAlchemy? As for workaround, is there a way how I can at least determine whether the Table object is a view and issue manual DROP VIEW statement by myself? Stefan Urbanek -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this

Re: [sqlalchemy] SQLite problem: column aliases with dot are stripped

2012-04-29 Thread Stefan Urbanek
On 28.4.2012, at 18:39, Michael Bayer wrote: > > On Apr 28, 2012, at 5:52 AM, Stefan Urbanek wrote: > >> This is what I used as workaround [1]: >> >> # select is sqlalchemy.sql.expression.select() >> # each selected column was derived as colu

Re: [sqlalchemy] SQLite problem: column aliases with dot are stripped

2012-04-28 Thread Stefan Urbanek
expect the sqlalchemy.sql.expression.select.column always return final list of selected columns. I haven't tested yet whether this will work with aggregations or any other computed expressions as well, but I see no reason why it should not. Regards, Stefan [1] https://github.com/St

[sqlalchemy] SQLite problem: column aliases with dot are stripped

2012-04-26 Thread Stefan Urbanek
Hi, I had this problem ~year ago (see [1]). Now with SQLAlchemy 0.7.6 I am having this same problem back again. Here is a piece of code that shows this behaviour, in comparison to other backends as well: https://gist.github.com/2506388 Verbosity and non-reusing instances is intentional. Is th

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

2012-04-24 Thread Stefan Urbanek
t; statements ># so they can be pasted and run in sql developer! >out.write(('%s' % > sql.compile(dialect=engine.dialect)).strip()+';\n/\n') >engine = create_engine('oracle://', strategy='mock', executor=dump) > &

[sqlalchemy] How to get DDL string from metadata?

2012-04-24 Thread Stefan Urbanek
Hi, How can I get a string that is going to be executed without executing it? Example code: from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String engine = create_engine("sqlite://") metadata = MetaData(engine) table = Table("foo", metadata) table.append_column(Column(

[sqlalchemy] Re: When creating many-to-many relationship I get: NoReferencedTableError

2012-02-08 Thread Stefan Urbanek
? Obviously you're passing 'cards.id' as a string so that the > order doesn't matter, but have you tried it anyway? > > > > > > > > -Original Message- > From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On > Behalf Of Stefa

[sqlalchemy] When creating many-to-many relationship I get: NoReferencedTableError

2012-02-08 Thread Stefan Urbanek
Hi, I am trying to create a simple many-to-many relationship using PostgreSQL in a specific schema ('cards'). I do it like this: class BaseObject(object): id = Column(Integer, primary_key=True) date_created = Column(DateTime) date_modified = Column(DateTime) collection_cards = Table

[sqlalchemy] Cubes OLAP: Examples for SQL backend

2011-11-28 Thread Stefan Urbanek
esign decisions and bugs). Regards, Stefan Urbanek data analyst and data brewmaster Twitter: @Stiivi Home: http://stiivi.com Brewery: http://databrewery.org Github: https://github.com/Stiivi -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group.

[sqlalchemy] sqlalchemy could not determine dialect when used with py2app

2011-05-18 Thread Stefan Urbanek
Hi, I have a quite "niche" problem: I am trying to create a stand-alone mac application with py2app - just wraped a web service in an app bundle. My app uses sqlalchemy and postgres (psycopg2). When I try to run the application I get (in Console): ... File "sqlalchemy/engine/url.pyc", line 116, i

[sqlalchemy] Re: Selecting columns with dots in their names

2011-03-02 Thread Stefan Urbanek
I apologize for replying to my own post, just found out that it works as expected with the latest fresh release 0.7b2 -downloaded and installed manually. it does not work with the version installed by easy_install, i think it was 0.6.6. On Mar 3, 12:18 am, Stefan Urbanek wrote: > Hi, > &g

[sqlalchemy] Selecting columns with dots in their names

2011-03-02 Thread Stefan Urbanek
Hi, I have a table with column names that contain dots, like "category.name" or "category.desc". When I do: stmt = table.select(whereclause = condition) cursor = connection.execute(stmt) print cursor.keys() I will get just [ ... "name", "desc" ] - nothing before the dot '.'. Whe

[sqlalchemy] Brewery: Heterogenous data streams with SQL Alchemy

2011-01-21 Thread Stefan Urbanek
you have any suggestions, comments? If anyone would like to try it and will have any troubles, just drop me a line and I will help. Regards, Stefan Urbanek -- Twitter: @Stiivi -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to