LocalDB from DataGrip and Python

You can connect to it, but not it’s not quite obvious how! First, you need “Microsoft SQL Server” data source:

Then, driver needs to be jTds because standard driver does not support named pipes transport which LocalDB is using. Connection type should be LocalDB and you need to choose the local instance. That’s it!

Warning! LocalDB really sucks even on small workloads (700Mb table) using 18Gb RAM on a simple join:

Data Location

The .mdf files for databases you create will be located in C:\Users\[username] folder.

Using from Python

First, start the emulator:

SqlLocalDB start

Simple query using pyodbc:

import pyodbc
import contextlib

with contextlib.closing(pyodbc.connect(f"DRIVER={{ODBC Driver 17 for SQL Server}};SERVER=(localdb)\\MSSQLLocalDB;DATABASE=mydb;integrated security=true;")) as cnxn:
    with contextlib.closing(cnxn.cursor()) as cursor:
        print(cursor.execute("select @@version;").fetchone())

To contact me, send an email anytime or leave a comment below.