Giter Site home page Giter Site logo

mssqlserver_pandas's Introduction

Using Microsoft SQL SQLSERVER with Python Pandas

Using Python Pandas dataframe to read and insert data to Microsoft SQL Server.


Cloning the repository

You can follow the steps below to clone the repository.

git clone  https://github.com/tomaztk/MSSQLSERVER_Pandas.git

Quickstart from Microsoft SQL Server

  1. Clone the repository
  2. Get connection to your SQL Server 2017+
  3. Start using MSSQL Server with Python Pandas
-- sample table
SELECT TOP 10 
   name
  ,object_id
FROM sys.tables


EXECUTE sp_execute_external_script @language = N'Python'
      ,@script = N'
      import pandas as pd
      OutputDataSet = pd.DataFrame(InputDataSet);
      '
      , @input_data_1 = N'SELECT TOP 10 name,object_id FROM sys.tables'
WITH RESULT SETS((
        [Name] VARCHAR(150) NOT NULL
       ,[object_ID] CHAR(20) NOT NULL
         ));

Quickstart from Python IDE

  1. Clone the repository
  2. Open Python IDE
  3. Enjoy
import pandas as pd
import pyodbc

sql_conn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};  \
           SERVER=SQLSERVER2017;DATABASE=master;Trusted_Connection=yes') 
query = "SELECT * FROM sys.tables"
df = pd.read_sql(query, sql_conn)

df.head(3)

Collaboration and contributors

Contributions of any kind is highly appreciated! Fork the repository, add your code.

Contact

Feel free to get in touch for questions regarding Python and MSSQL Server connectivity.

mssqlserver_pandas's People

Contributors

tomaztk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.