[sqlalchemy] SELECT ... INTO Contribution

2018-11-06 Thread Paul Becotte
Hi!

I recently needed to use the select ... into ... construct to build a temp 
table in Redshift. I used the 
recipe https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/SelectInto 
here to get a good idea of how to go about this, and was wondering if I 
should contribute the final working version back to the project. The 
biggest thing that gives me pause is that the recipe says that this would 
be added in 2014, and it hasn't been, so I feel like you probably have a 
good reason that I am ignorant about! The other, less of a blocker, is that 
I am not actually sure of a comprehensive list of database engines that 
support don't support this- I know Postgres, Snowflake, Redshift, and MSSQL 
do... but I am out of expertise at that point. For something like this that 
may or may not be supported in all database engines, are there good 
examples of how that should be handled in the existing code base?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] gevent.monkey.patch_all() breaks my Sqlalchemy connection...

2016-07-19 Thread Paul Becotte
Hi!  So, I have a traditional Flask app using flask-sqlalchemy and 
sqlalchemy ORM, served with uwsgi.  Uwsgi is set with processes=4 and 
threads=4.  Yesterday I added grequests to improve a single area of the app 
a bit (I had to do a couple hundred external API calls to build a single 
data structure).  No problem- except that I started getting errors like 

/usr/local/lib/python2.7/dist-packages/flask_sqlalchemy/__init__.py", line 
423, in first_or_404 rv = self.first() File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 
2634, in first ret = list(self[0:1]) File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 
2457, in __getitem__ return list(res) File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 
2736, in __iter__ return self._execute_and_instances(context) File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 
2751, in _execute_and_instances result = 
conn.execute(querycontext.statement, self._params) File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 
914, in execute return meth(self, multiparams, params) File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 
323, in _execute_on_connection return 
connection._execute_clauseelement(self, multiparams, params) File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 
1010, in _execute_clauseelement compiled_sql, distilled_params File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 
1078, in _execute_context None, None) File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 
1341, in _handle_dbapi_exception exc_info File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 
200, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, 
cause=cause) File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 
1073, in _execute_context context = constructor(dialect, self, conn, *args) 
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", 
line 558, in _init_compiled self.cursor = self.create_cursor() File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 
748, in create_cursor return self._dbapi_connection.cursor() File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 852, in 
cursor return self.connection.cursor(*args, **kwargs) File 
"/usr/local/lib/python2.7/dist-packages/mysql/connector/connection.py", 
line 807, in cursor raise errors.OperationalError("MySQL Connection not 
available.") OperationalError: (mysql.connector.errors.OperationalError) 
MySQL Connection not available. 


>From playing around with it, importing grequests was the line of code that 
made the error appear/dis-appear.  Further experimenting shows that `import 
gevent.monkey; gevent.monkey.patch_all()` anywhere in the code breaks the 
app as well.  This doesn't happen on every request, and I am not actually 
using greenlets or the gevent loop anywhere in the endpoints I am 
accessing.  For now this is easy enough for me to just rip out grequests, 
but I was wondering if anyone had any ideas as to why this is happening?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.