Comments (2)
Ah yes master is broken, see the tests on Travis. #92 (comment)
from sqlalchemy-redshift.
Similar problem with latest version from pypi - anyway this example still doesn't work:
EXAMPLE 1 BEFORE: None Example #1
Traceback (most recent call last):
File "test.py", line 50, in <module>
print("EXAMPLE 1 AFTER: ", example_1.id, example_1.name)
File "/tmp/env/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 237, in __get__
return self.impl.get(instance_state(instance), dict_)
File "/tmp/env/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 579, in get
value = state._load_expired(state, passive)
File "/tmp/env/lib/python2.7/site-packages/sqlalchemy/orm/state.py", line 592, in _load_expired
self.manager.deferred_scalar_loader(self, toload)
File "/tmp/env/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 703, in load_scalar_attributes
raise orm_exc.ObjectDeletedError(state)
sqlalchemy.orm.exc.ObjectDeletedError: Instance '<IdentityExample at 0x7f0da95b68d0>' has been deleted, or its row is otherwise not present.
If I set engine.echo = True
, I get the following:
2017-06-01 09:08:29,163 INFO sqlalchemy.engine.base.Engine select version()
2017-06-01 09:08:29,163 INFO sqlalchemy.engine.base.Engine {}
2017-06-01 09:08:29,618 INFO sqlalchemy.engine.base.Engine select current_schema()
2017-06-01 09:08:29,618 INFO sqlalchemy.engine.base.Engine {}
2017-06-01 09:08:30,073 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2017-06-01 09:08:30,073 INFO sqlalchemy.engine.base.Engine {}
2017-06-01 09:08:30,301 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2017-06-01 09:08:30,301 INFO sqlalchemy.engine.base.Engine {}
2017-06-01 09:08:30,982 INFO sqlalchemy.engine.base.Engine select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where pg_catalog.pg_table_is_visible(c.oid) and relname=%(name)s
2017-06-01 09:08:30,983 INFO sqlalchemy.engine.base.Engine {'name': u'identity_example'}
2017-06-01 09:08:31,445 INFO sqlalchemy.engine.base.Engine
DROP TABLE identity_example
2017-06-01 09:08:31,445 INFO sqlalchemy.engine.base.Engine {}
2017-06-01 09:08:31,920 INFO sqlalchemy.engine.base.Engine COMMIT
2017-06-01 09:08:32,152 INFO sqlalchemy.engine.base.Engine select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where pg_catalog.pg_table_is_visible(c.oid) and relname=%(name)s
2017-06-01 09:08:32,153 INFO sqlalchemy.engine.base.Engine {'name': u'identity_example'}
1 before None john
2017-06-01 09:08:32,850 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2017-06-01 09:08:32,856 INFO sqlalchemy.engine.base.Engine INSERT INTO identity_example (name) VALUES (%(name)s)
2017-06-01 09:08:32,857 INFO sqlalchemy.engine.base.Engine {'name': 'Example #1'}
2017-06-01 09:08:33,331 INFO sqlalchemy.engine.base.Engine COMMIT
2017-06-01 09:08:33,695 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2017-06-01 09:08:33,696 INFO sqlalchemy.engine.base.Engine SELECT identity_example.id AS identity_example_id, identity_example.name AS identity_example_name
FROM identity_example
WHERE identity_example.id = %(param_1)s
2017-06-01 09:08:33,696 INFO sqlalchemy.engine.base.Engine {'param_1': 0}
Traceback (most recent call last):
File "test.py", line 50, in <module>
print("EXAMPLE 1 AFTER: ", example_1.id, example_1.name)
File "/tmp/env/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 237, in __get__
return self.impl.get(instance_state(instance), dict_)
File "/tmp/env/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 579, in get
value = state._load_expired(state, passive)
File "/tmp/env/lib/python2.7/site-packages/sqlalchemy/orm/state.py", line 592, in _load_expired
self.manager.deferred_scalar_loader(self, toload)
File "/tmp/env/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 703, in load_scalar_attributes
raise orm_exc.ObjectDeletedError(state)
sqlalchemy.orm.exc.ObjectDeletedError: Instance '<IdentityExample at 0x7f0da95b68d0>' has been deleted, or its row is otherwise not present.
For me it looks like redshift-sqlalchemy
uses ResultProxy.lastrowid
, but for some reason (I could not figure it out yet) that value for RedShift is always 0
, regardless of which ID was created or was not created.
The only way I know to obtain an ID of newly inserted record is to SELECT max(id) FROM table
within the same transaction, which is probably not consistent but should hopefully work at least partially.
from sqlalchemy-redshift.
Related Issues (20)
- Drop support for EOL versions of python HOT 2
- support sqlalchemy 2.0 HOT 23
- Use bind parameters
- Update project CI
- Regression causing errors during reflection for 1.4 FutureEngine HOT 5
- Log handler added in v0.8.13 produces duplicate logs in application
- Regression in v0.8.13: table reflection broken for non-superusers HOT 2
- Do not run integration tests with dbuser having elevated permissions HOT 1
- Migration error: 'Relation "alembic_version" already exists'
- Alembic migration issue: alter table
- Alembic migrations use RETURNING on update
- Performance degradation and memory peaks when updating from 0.8.12
- Class method needs updating HOT 1
- Table Reflection Slowness
- Temp Table Reflection
- Programming Error with percentile_cont HOT 1
- statements save OIDs unless commited
- Proposal: Remove pkg_resources from the fast path
- Any way to support sqlalchemy >= 2.0? HOT 3
- util.text_type issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlalchemy-redshift.