python


How do I use SQLalchemy to treat an existing select object as a view?


I have a select object s1 and I would like to treat it as a view, so that I can join other tables onto it. I have tried something like this:
s1 = select([t1], ...)
s2 = s1.join(t2, t1.c.id==t2.c.id)
but I get an error:
sqlalchemy.exc.StatementError: Not an executable clause
I have tried this:
s1 = select([t1], ...)
s2 = select([t1, t2], from_obj=s1.alias().join(t2, t1.c.id==t2.c.id))
but I get this error:
sqlalchemy.exc.ProgrammingError: (ProgrammingError) invalid reference to FROM-clause entry for table "t1"
The reason I need to do this is because s1 is returned from a function that applies a complex where clause and I'd rather not rebuild that where clause when constructing s2.

Related Links

too many threads due to synch communication
How can I specify a relative path in a Python logging config file?
Python “draw() must be called with Label instance as first argument (got _WindowMetaclass instance instead)”
Writing to a file in Python inserts null bytes
Disable logging during manage.py test?
turbogears request/user object in templates and request context
Django date filter to output “am” or “A.M.”
Schedule Python Script - Windows 7
slicing arrays in numpy/scipy
Recommendations for a simple 2D graphics python library that can output to screen and pdf?
Reading numpy arrays outside of Python
Return value from thread
Is this control structure a code smell?
Django: How do I validate unique_together from within the model
Munging non-printable characters to dots using string.translate()
Error when using astWCS trying to create WCS object

Categories

HOME
spring
vue.js
uibutton
travis-ci
h2
tumblr
devstack
codeblocks
shipping
dropbear
click
powershell-v3.0
intellij-plugin
symfony-forms
store
rebol2
bar-chart
phpbb
internet-explorer-8
google-api-java-client
jogl
primes
tortoisegit
backpropagation
uiautomator
rails-activerecord
philips-hue
osmdroid
ab-initio
reply
winscp
aurelia-binding
forum
vertex-buffer
bitcoin-testnet
gpib
getjson
lmdb
hawtio
reactivemongo
windows-10-iot-core
nunit-3.0
broadleaf-commerce
rhel.net
es-shell
image-compression
duktape
android-preferences
paho
bids
startapp
cgcontext
mcrypt
paas
project-template
rmongodb
unsatisfiedlinkerror
spring-repositories
multilingual-app-toolkit
scriptlet
qt-linguist
cctray
sonarqube5.3
direct3d12
persistence.xml
data-import
jenkins-scriptler
rad
ffserver
harp
power-law
getimagedata
alpha-transparency
phpdocx
broadcasting
openkinect
roxygen
wic
nscolor
installshield-2009
lame
iconv
database-permissions
cbcentralmanager
ubuntu-11.10
usn
n-layer
fotoware
die
userid
supersized
cross-domain-policy
charts4j
sendfile
camtasia
pci-bus
filetime
lazy-c++
system-codedom-compiler
inline-if
virtualquery
ajaxpro
self-reference

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App