Is there a way to output all the SQL statements into a file? I don't mean a logging file with other information, I mean a file with **only** SQL statements, which could ideally be run as it is from within my database client.
I tried setting echo=True, and I also tried this: http://stackoverflow.com/questions/6350411/how-to-retrieve-executed-sql-code-from-sqlalchemy but I can't spot anything out of the ordinary. I profiled the code, and saw that 99% of the time is spent in the do_executemany method of sqlalchemy\engine\default.py , which arguably doesn't reveal much per se unless I understand better how pandas.DataFrame.to_sql calls sqlachemy Lastly, do you know of any settings / parameters / hacks which could speed up sqlalchemy's connection to a SQL server database? Thanks! On Tuesday, April 21, 2015 at 9:52:01 PM UTC+1, Michael Bayer wrote: > > > Unfortunately I don't work with Pandas so this is dependent on how Pandas > is doing their queries here. > > If you can at least set echo=True on the engine here, you'd see what > queries are being emitted. Whether they are emitting a handful of > queries, or thousands, makes a difference, as well as if these queries are > returning vast numbers of rows due to cartesian products or similar makes a > difference, and how they are fetching rows back makes a difference. > > It would be helpful to everyone if either you or someone on the Pandas > development team could walk through the steps detailed at > http://docs.sqlalchemy.org/en/rel_1_0/faq/performance.html#how-can-i-profile-a-sqlalchemy-powered-application > > to isolate where the performance issue is originating. > > > > Thanks! > > > My code looks like this: > > import pandas as pdfrom sqlalchemy import create_engine, MetaData, Table, > selectServerName = "myserver"Database = "mydatabase"TableName = "mytable" > > engine = create_engine('mssql+pyodbc://' + ServerName + '/' + Database) > conn = engine.connect() > > metadata = MetaData(conn) > > my_data_frame.to_sql(TableName,engine) > > > -- > 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+...@googlegroups.com <javascript:>. > To post to this group, send email to sqlal...@googlegroups.com > <javascript:>. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > > > -- 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 http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.