question

DrewDerenthal-6582 avatar image
0 Votes"
DrewDerenthal-6582 asked DrewDerenthal-6582 answered

Python SQL Server Example Issue

I have walked through the Microsoft documentation for python integration with SQL Server using pyodbc and revoscalepy:

https://docs.microsoft.com/en-us/sql/machine-learning/python/setup-python-client-tools-sql?view=sql-server-ver15#6---test-remote-connection

I have run all steps successfully until 5-3 (using revoscalepy to create table and load Iris data). I am able to create a database using pyodbc as demonstrated in 5-1, but in 5-3, code runs without error, it signifies the appropriate amount of rows successfully read and written, but no table appears in SQL Server.

Has anyone else successfully walked through this tutorial?

Thank you.

from revoscalepy import RxSqlServerData, rx_data_step

Example of using RX APIs to load data into SQL table. You can also do this with pyodbc

table_ref = RxSqlServerData(connection_string=connection_string.format(new_db_name), table="iris_data")
rx_data_step(input_data = df, output_file = table_ref, overwrite = True)

print("New Table Created: Iris")
print("Sklearn Iris sample loaded into Iris table")

122382-image.png


sql-server-generalazure-data-science-vm
image.png (7.5 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello,

May I know the version of SQL server and Python version you are using? I try to reproduce your issue on my side with the same setting.

Regards,
Yutong

0 Votes 0 ·
DrewDerenthal-6582 avatar image
0 Votes"
DrewDerenthal-6582 answered

My mistake, the tutorial was working. It was writing to the "master" database instead of the new database created. Thank you.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DrewDerenthal-6582 avatar image
0 Votes"
DrewDerenthal-6582 answered ErlandSommarskog commented

SQL Server Version 15.0.18206.0
Python Version 3.5.2

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The version number for SQL Server looks a little funny. There are usually only four digits in the third component. Might you have looked in Help->About in Management Studio? In that case you get the version number for SSMS, which is not SQL Server.

What we want is the output from "SELECT @@version".

0 Votes 0 ·