App: app.bootstrap_new [debug]
Instance: /Users/hugo/Dropbox/lahey/api/instance
>>> from app.extensions import db
>>> from app.models.user import User
>>> user = User.query.all()[0]
>>> db.session.delete(user)
>>> db.session.commit()
Traceback (most recent call last):
 File "<console>", line 1, in <module>
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 153, in do
  return getattr(self.registry(), name)(*args, **kwargs)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 937, in commit
  self.transaction.commit()
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 461, in commit
  self._prepare_impl()
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 441, in _prepare_impl
  self.session.flush()
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2237, in flush
  self._flush(objects)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2363, in _flush
  transaction.rollback(_capture_exception=True)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
  compat.reraise(exc_type, exc_value, exc_tb)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
  raise value
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2327, in _flush
  flush_context.execute()
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 370, in execute
  postsort_actions = self._generate_actions()
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 329, in _generate_actions
  if action.execute(self):
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 454, in execute
  self.dependency_processor.presort_deletes(uow, delete_states)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/dependency.py", line 419, in presort_deletes
  self._passive_delete_flag)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 225, in get_attribute_history
  attributes.LOAD_AGAINST_COMMITTED)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 928, in get_history
  current = self.get(state, dict_, passive=passive)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 603, in get
  value = self.callable_(state, passive)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/strategies.py", line 623, in _load_for_state
  return self._emit_lazyload(session, state, ident_key, passive)
 File "<string>", line 1, in <lambda>
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/strategies.py", line 747, in _emit_lazyload
  result = q(session).params(**params).all()
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/ext/baked.py", line 399, in all
  return list(self)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/ext/baked.py", line 296, in __iter__
  baked_context = bq._bake(self.session)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/ext/baked.py", line 198, in _bake
  query = self._as_query(session)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/ext/baked.py", line 221, in _as_query
  query = step(query)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/orm/strategies.py", line 727, in <lambda>
  strategy_options.Load.for_existing_path(
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 977, in __getattr__
  attr = getattr(self.module, key)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 767, in __get__
  obj.__dict__[self.__name__] = result = self.fget(obj)
 File "/Users/hugo/Dropbox/lahey/api/.venv/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 962, in module
  % (self._il_path, self._il_addtl))
ImportError: importlater.resolve_all() hasn't been called (this is sqlalchemy.orm strategy_options)
import datetime
from sqlalchemy_utils.types.password import PasswordType
from sqlalchemy_utils import force_auto_coercion
from app.extensions import db
# Setup coercion of passwords
force_auto_coercion()
class User(db.Model):
 id = db.Column(db.Integer, primary_key=True)
 email = db.Column(db.String(120), unique=True, nullable=False)
 password = db.Column(PasswordType(schemes=['pbkdf2_sha512']), nullable=False)
 name = db.Column(db.String(256))
 created_at = db.Column(db.DateTime, default=datetime.datetime.now)
 updated_at = db.Column(db.DateTime, onupdate=datetime.datetime.now)
--
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.
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/kz47tCpbf-A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscribe@googlegroups.com.