Re: [sqlalchemy] Oracle - How to select from a table partition? - SELECT FROM table PARTITION (p0)

2018-03-28 Thread Mike Bayer
On Wed, Mar 28, 2018 at 7:07 PM, Matthew Moisen wrote: > I have an Oracle partitioned table created like so: > > DROP TABLE foos; > > CREATE TABLE foos ( > bar VARCHAR2(10) > ) PARTITION BY HASH (bar) ( > PARTITION P0, > PARTITION P1, > PARTITION P2, >

[sqlalchemy] Oracle - How to select from a table partition? - SELECT FROM table PARTITION (p0)

2018-03-28 Thread Matthew Moisen
I have an Oracle partitioned table created like so: DROP TABLE foos; CREATE TABLE foos ( bar VARCHAR2(10) ) PARTITION BY HASH (bar) ( PARTITION P0, PARTITION P1, PARTITION P2, PARTITION P3 ); CREATE TABLE hellos ( bar VARCHAR2(10) ); I want to be able to issue deep,

howto transform sql create table to alembic

2018-03-28 Thread marek cervenka
hi, i read alembic documentation but its still hard for me transform this example table to alembic CREATE TABLE `user_properties` ( `users_id` int(11) NOT NULL COMMENT 'ID from users table', `property_name` varchar(255) NOT NULL COMMENT 'property key', `property_value` mediumtext NOT

Re: [sqlalchemy] Custom utcnow function and session.execute yields a constant timestamp

2018-03-28 Thread Nadav Goldin
Thats the issue indeed, thanks! On Wed, Mar 28, 2018 at 11:05 PM, Jonathan Vanasco wrote: > in postgres > > returns the start of the current transaction: > NOW() > CURRENT_DATE > CURRENT_TIME > CURRENT_TIMESTAMP > LOCALTIME > LOCALTIMESTAMP > > returns the actual time: >

Re: [sqlalchemy] Custom utcnow function and session.execute yields a constant timestamp

2018-03-28 Thread Jonathan Vanasco
in postgres returns the start of the current transaction: NOW() CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP LOCALTIME LOCALTIMESTAMP returns the actual time: clock_timestamp() timeofday() -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post

Re: [sqlalchemy] Custom utcnow function and session.execute yields a constant timestamp

2018-03-28 Thread Mike Bayer
try calling it in a new transaction, it's likely constant per transaction time. $ psql -U scott test psql (9.6.8) Type "help" for help. test=# begin; BEGIN test=# select now(); now -- 2018-03-28 15:03:09.82421-04 (1 row) test=# select now();

[sqlalchemy] Custom utcnow function and session.execute yields a constant timestamp

2018-03-28 Thread ngoldin
Hi, I've created the following utcnow function as described here: http://docs.sqlalchemy.org/en/latest/core/compiler.html?highlight=utc#utc-timestamp-function from sqlalchemy.ext.compiler import compiles from sqlalchemy.sql import expression from sqlalchemy.types import DateTime, String class

Re: [sqlalchemy] Cascade delete-orphan: reattach child to another parent

2018-03-28 Thread Mike Bayer
the backrefs intentionally don't keep fanning deep into object graph for this kind of thing, so if you want it to go one hop further you can add an event to do that directly: from sqlalchemy import event from sqlalchemy.orm import attributes @event.listens_for(Address.user, "set") def

Re: [sqlalchemy] How call procedure with output params?

2018-03-28 Thread Mike Bayer
there's no OUT param or SP support for SQL Server directly, we ask that you use the DBAPI interface directly: http://docs.sqlalchemy.org/en/latest/core/connections.html#calling-stored-procedures you'll have to consult with your DBAPI how the OUT parameters work. On Tue, Mar 27, 2018 at 2:53

[sqlalchemy] Cascade delete-orphan: reattach child to another parent

2018-03-28 Thread Serhii Mozghovyi
Is it possible to make child objects (many-to-one side) delete itself from the old parent's collection when it is added to a different parent? See the file attached. The old parent remains unaware that he doesn't have this child anymore. P.S. session.expire() is an obvious solution but too