Re: [sqlalchemy] Re: pandas to MS SQL DataWarehouse (to_sql)

2018-10-12 Thread Jingting Lu
Hi Dirk,

Happy to report that there are more projects using dw.  I have the same 
issues here.  Using Azure SQL DW at the moment and building a serverless 
function app that reads and sends data back to the SQL DW.
Did you eventually find a solution other than looping through the dataframe?

Cheers,
Nicole

On Wednesday, September 13, 2017 at 5:39:47 PM UTC-5, dirk.biesinger wrote:
>
> yeah, I ran into some 'nice' 'features' in this project.
> the azure datawarehouse does not behave or work like a typical old-school 
> sql server.
> There might be some potential there, just not sure how many projects would 
> be using the datawarehouse
>
> On Wednesday, September 13, 2017 at 3:33:20 PM UTC-7, Mike Bayer wrote:
>>
>> On Wed, Sep 13, 2017 at 6:13 PM, dirk.biesinger 
>>  wrote: 
>> > "oh that is very interesting." he says and then it's getting eerily 
>> quiet. 
>> > I guess Mike and Dilly are somewhere in the depth of code and docs... 
>>
>>
>> unfortunately not, azure seems to offer free trials if you are willing 
>> to give them a credit card number so I can perhaps eventually get 
>> around to working with that but at the moment it would be preferable 
>> if someone wants to work on an azure variant of the SQL Server 
>> dialect.It shouldn't be hard but the various glitches need to be 
>> understood for anything to be committed. 
>>
>> > 
>> > On Wednesday, September 13, 2017 at 2:05:22 PM UTC-7, Mike Bayer wrote: 
>> >> 
>> >> On Wed, Sep 13, 2017 at 4:29 PM, dirk.biesinger 
>> >>  wrote: 
>> >> > 
>> >> > as for the rollback call, 
>> >> > adding it after the print command, does not change anything. 
>> >> > When I insert it between cursor.execute() and rows = 
>> cursor.fetchall(), 
>> >> > I 
>> >> > get an error as expected. 
>> >> 
>> >> oh that is very interesting. 
>> >> 
>> >> 
>> >> > 
>> >> > 
>> >> > On Wednesday, September 13, 2017 at 1:16:59 PM UTC-7, Mike Bayer 
>> wrote: 
>> >> >> 
>> >> >> On Wed, Sep 13, 2017 at 3:58 PM, dirk.biesinger 
>> >> >>  wrote: 
>> >> >> > using 
>> >> >> > 
>> >> >> > connection = pyodbc.connect() 
>> >> >> > connection.autocommit = 0 
>> >> >> > cursor = connection.cursor() 
>> >> >> > cursor.execute([proper sql statement that references a table]) 
>> >> >> > rows = corsor.fetchall() 
>> >> >> > print(rows) 
>> >> >> > cursor.close() 
>> >> >> > 
>> >> >> > gives me the output out of the table that I expect. 
>> >> >> > So if you were wondering if a raw pyodbc connection works, this 
>> is 
>> >> >> > confirmed. 
>> >> >> 
>> >> >> did you call: 
>> >> >> 
>> >> >> connection.rollback() 
>> >> >> 
>> >> >> the stack traces you have given me indicate this method cannot be 
>> >> >> called else Azure raises an error.  This must be illustrated as 
>> >> >> definitely the problem, and not a side effect of something else. 
>> >> >> 
>> >> >> This is why this would go a lot quicker if someone had a *blank* 
>> azure 
>> >> >> database on a cloud node somewhere for me to log into.  I don't 
>> need 
>> >> >> your customer data. 
>> >> >> 
>> >> >> 
>> >> >> 
>> >> >> 
>> >> >> 
>> >> >> 
>> >> >> > 
>> >> >> > On Wednesday, September 13, 2017 at 12:49:33 PM UTC-7, Mike Bayer 
>> >> >> > wrote: 
>> >> >> >> 
>> >> >> >> On Wed, Sep 13, 2017 at 3:27 PM, dirk.biesinger 
>> >> >> >>  wrote: 
>> >> >> >> > I have the 'patched' pyodbc.py file active. 
>> >> >> >> > Executing your code snippet does NOT produce an error or any 
>> >> >> >> > output 
>> >> >> >> > for 
>> >> >> >> > that 
>> >> >> >> > matter. 
>> >> >> >> > 
>> >> >> >> > 
>> >> >> >> > On Wednesday, September 13, 2017 at 12:22:30 PM UTC-7, Mike 
>> Bayer 
>> >> >> >> > wrote: 
>> >> >> >> >> 
>> >> >> >> >> On Wed, Sep 13, 2017 at 3:14 PM, dirk.biesinger 
>> >> >> >> >>  wrote: 
>> >> >> >> >> > Got ya, 
>> >> >> >> >> > 
>> >> >> >> >> > so we could solve the issue on the sqlalchemy end with the 
>> >> >> >> >> > alteration 
>> >> >> >> >> > of 
>> >> >> >> >> > the 
>> >> >> >> >> > pyodbc.py file. 
>> >> >> >> >> > I assume you'll include this in the next release? 
>> >> >> >> >> 
>> >> >> >> >> um. 
>> >> >> >> >> 
>> >> >> >> >> can you just confirm for me this makes the error? 
>> >> >> >> >> 
>> >> >> >> >> 
>> >> >> >> >> connection = pyodbc.connect() 
>> >> >> >> >> connection.autocommit = 0 
>> >> >> >> >> connection.rollback() 
>> >> >> >> 
>> >> >> >> 
>> >> >> >> try it like this: 
>> >> >> >> 
>> >> >> >> 
>> >> >> >> connection = pyodbc.connect() 
>> >> >> >> connection.autocommit = 0 
>> >> >> >> cursor = connection.cursor() 
>> >> >> >> cursor.execute("SELECT 1") 
>> >> >> >> cursor.close() 
>> >> >> >> 
>> >> >> >> connection.rollback() 
>> >> >> >> 
>> >> >> >> 
>> >> >> >> >> 
>> >> >> >> >> 
>> >> >> >> >> 
>> >> >> >> >> > The issue with creating a table when the option 
>> >> >> >> >> > "if_exists='append'" 
>> >> >> >> >> > is 
>> >> >> >> >> > set 
>> >> >> >> >> > in the df.to_sql() call, is a pandas problem. 
>> >> >> >> >> > 
>> >> >> >> >> > Thank you for 

Re: [sqlalchemy] SQLAlchemy Foreign Key Issues with Db2

2018-10-12 Thread Mike Bayer
hi there -

for DB2 issues that's an external dialect supported by IBM, please
post at https://groups.google.com/forum/#!forum/ibm_db


On Fri, Oct 12, 2018 at 11:46 AM Brian T  wrote:
>
> I'm running SQLAlchemy 1.2.12.  When trying to autoload a DB2 table, it gives 
> me a "no such table" error for a table referenced in a foreign key, even 
> though that table exists.
>
> import sqlalchemy
>
> cnxstr = 'ibm_db_sa://xyzzy'
> db2 = sqlalchemy.create_engine(cnxstr)
> meta = sqlalchemy.MetaData(db2)
> tbl = sqlalchemy.Table('child_table', meta, schema='plugh', 
> autoload_with=db2)
>
> NoSuchTableError: parent_table
>
> Not that this code works fine -- SQLAlchemy is able to find the parent table 
> in other contexts.
>
> tbl = sqlalchemy.Table('parent_table', meta, schema='plugh', 
> autoload_with=db2)
>
> I'm also able to construct the tables by hand using the inspector.  It's only 
> when I use Autoload that I run into this problem.  Is there a way to fix the 
> autoload?
>
> --
> 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 - 
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] SQLAlchemy Foreign Key Issues with Db2

2018-10-12 Thread Brian T
I'm running SQLAlchemy 1.2.12.  When trying to autoload a DB2 table, it 
gives me a "no such table" error for a table referenced in a foreign key, 
even though that table exists.

import sqlalchemy

cnxstr = 'ibm_db_sa://xyzzy'
db2 = sqlalchemy.create_engine(cnxstr)
meta = sqlalchemy.MetaData(db2)
tbl = sqlalchemy.Table('child_table', meta, schema='plugh', 
autoload_with=db2)

NoSuchTableError: parent_table

Not that this code works fine -- SQLAlchemy is able to find the parent 
table in other contexts.

tbl = sqlalchemy.Table('parent_table', meta, schema='plugh', 
autoload_with=db2)

I'm also able to construct the tables by hand using the inspector.  It's 
only when I use Autoload that I run into this problem.  Is there a way to 
fix the autoload?

-- 
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.