Live data from Hacker News

Microsoft Python Driver for SQL Server

github.com

11–20 of 35 posts

Re: Microsoft Python Driver for SQL Server

#11
I’ve been working with SQL Server from Python on various platforms for several years. The new Microsoft driver looks promising, particularly for constrained environments where configuring ODBC has historically been a source of friction.

For large data transfers — for example, Pandas or Polars DataFrames with millions of rows — performance and reliability are critical. In my experience, fast_executemany in combination with SQLAlchemy helps, but bulk operations via OpenRowSets or BCP are still the most predictable in production, provided the proper permissions are set.

It’s worth noting that even with a new driver, integration complexity often comes from platform differences, TLS/SSL requirements, and corporate IT policies rather than the library itself. For teams looking to simplify workflows, a driver that abstracts these nuances while maintaining control over memory usage and transaction safety would be a strong improvement over rolling your own ODBC setup.

Re: Microsoft Python Driver for SQL Server

#12

I’ve been working with SQL Server from Python on various platforms for several years. The new Microsoft driver looks promising, particularly for constrained environments where configuring ODBC has historically been a source of friction. For large data transfers — for example, Pandas or Polars DataFrames with millions of rows — performance and reliability are critical. In my experience, fast_executemany in combination…

This is the correct prospective. Often driver issues transcend technical and political boundaries. My old team dropped a vendor who changed the features of a driver and spent several years trying to find another as well as making that vendor reapply and make a new case, which, didn't work out for them.

Re: Microsoft Python Driver for SQL Server

#13
post #12

I’ve been working with SQL Server from Python on various platforms for several years. The new Microsoft driver looks promising, particularly for constrained environments where configuring ODBC has historically been a source of friction. For large data transfers — for example, Pandas or Polars DataFrames with millions of rows — performance and reliability are critical. In my experience, fast_executemany in combination…

This is the correct prospective. Often driver issues transcend technical and political boundaries. My old team dropped a vendor who changed the features of a driver and spent several years trying to find another as well as making that vendor reapply and make a new case, which, didn't work out for them.

[deleted]

Re: Microsoft Python Driver for SQL Server

#14
post #6

Very cool. Used to be a huge pain to connect to sqlserver from Python (especially non Windows platforms).

I do expect this package to make connecting easier, but it was okay even before. ODBC connectivity via pyodbc has always worked quite well and it wasn't really any different when compared to any other ODBC source. I'm more on the data engineering side and I'm very picky about this kind of stuff, I don't expect the average user would even notice besides the initial pain of configuring ODBC from scratch.

IIRC, I had trouble if I installed the MS ODBC driver and some of the updates for Ubuntu (WSL) out of order. I generally prefer a language driver package where available.

Would be nice if MS and Deno could figure things out to get SQL working in Deno.

Re: Microsoft Python Driver for SQL Server

#15
post #3

What my workself would love is to easily dump Pandas or Polar data frames to SQL Tables in SQL Server as fast as possible. I see this bcp, but I don't see an example of uploading a large panda dataframe to SQL Server.

> What my workself would love is to easily dump Pandas or Polar data frames to SQL Tables in SQL Server as fast as possible

We run into this issue also where we want to upload volumes of data but don't want to assume access to BCP on every DB server.

We wrote a little utility that actually works pretty fast compared to other methods we've tested (fast=about 1,000,000 rows per minute for a table with 10 random columns with random data), here's the approach:

1-Convert rows into fixed length strings so each row is uploaded as one single varchar column (which makes parsing+execution of SQL stmt during upload much quicker)

2-Repeatedly upload groups of fixed length rows into temp table until all uploaded.

Details:

Multiple fixed length rows are combined into one fixed length varchar column that will be uploaded as one single raw buffer row. We found a buffer size of 15,000 to be the sweet spot.

Multiple threads will each process a subset of source data rows. We found 5 threads to be generally pretty good.

At the end of this step, the destination temp table will have X rows of buffers (the buffer column is just a varchar(15000), and inside each of those buffers are Y source data rows with Z number of columns in fixed format.

3-Once the buffer rows are all uploaded then split out the source data rows+columns using a temp sproc generated for the exact schema (e.g. substring(Buffer_Data,x,y) as Cust_Name)

Re: Microsoft Python Driver for SQL Server

#16
If MSSQL really wanted to become more mainstream they'd release a properly free version to compete with MySQL/MariaDB and PostgreSQL.

I've not used MSSQL since 2015/2016 and haven't missed much.

Now I live in the OLAP space so I think of it far, far less.

Re: Microsoft Python Driver for SQL Server

#18
post #2

This is really timely. I just needed to build a connector to Azure Fabric and it requires ODBC 18 which in turn requires openssl to allow deprecated and old versions of TLS. Now I can revert all of that and make it clean :)

Actually bad luck, it seems this doesn't support Microsoft Fabric with the datawarehouse engine... it fails because Fabric doesn't support the DECLARE CURSOR operation, which this driver relies on.

Re: Microsoft Python Driver for SQL Server

#19
post #3

What my workself would love is to easily dump Pandas or Polar data frames to SQL Tables in SQL Server as fast as possible. I see this bcp, but I don't see an example of uploading a large panda dataframe to SQL Server.

While bcp lacks some features to make this as straightforward as PostgreSQL for example, i.e. piped data into bcp, it is a fast ingest option for MSSQL.

We wound up staging a local tab delimited file, and importing via bcp:

    bcp "$DESTINATION_TABLE" in "$STAGE_FILE.dat" -u -F 2 -c -t'\t'
Not elegant, but it works.

Re: Microsoft Python Driver for SQL Server

#20

If MSSQL really wanted to become more mainstream they'd release a properly free version to compete with MySQL/MariaDB and PostgreSQL. I've not used MSSQL since 2015/2016 and haven't missed much. Now I live in the OLAP space so I think of it far, far less.

Money here means this won’t happen.

Sure, greenfield does not use MSSQL but there is a ton of companies stuck with MSSQL that will continue to have to fork over big licensing money.

Post reply on HN