machow / siuba

Python library for using dplyr like syntax with pandas and SQL
https://siuba.org
MIT License
1.14k stars 48 forks source link

Compatibility with SQL Server #469

Open uriahf opened 1 year ago

uriahf commented 1 year ago

Hi, thank you for this amazing work!

Does Siuba work with SQL Server?

Should be something like this:

import siuba
from siuba import _, sql
from siuba.sql import select, group_by
from siuba.dply.connections import connect

# Connect to SQL Server
conn = connect(
    host="hostname",
    port=1433,
    user="username",
    password="password",
    database="database_name",
    driver="ODBC Driver 17 for SQL Server"
)

# Create a query using the siuba package
query = (
    select(_.column1, _.column2)
    .from_("table_name")
    .where(_.column1 > 5)
    .group_by(_.column1)
)

# Execute the query
result = conn.query(query)

print(result)