Skip to content

Latest commit

 

History

History
81 lines (55 loc) · 1.21 KB

MSSQL.md

File metadata and controls

81 lines (55 loc) · 1.21 KB

How to use class MSSQL

Creating instance of class

You can create as many database connectors as you want.

from connectors_to_databases import MSSQL

m = MSSQL()

m_other = MSSQL(
    host='0.0.0.0',
    port=0,
    database='main',
    login='admin',
    password='admin',
)

Check connection to database

You can check connection to database.

m.check_connection()

Creating a table for examples

You can create table and execute any MSSQL query.

m.execute_script('CREATE TABLE simple_ (id int4)')

Filling the table with data

You can insert data from pandas dataframe in MSSQL table

# simple pd.DataFrame
df = pd.DataFrame(data={'id':[1]})

m.insert_df(
    df=df,
    m_table_name='simple_'
)

Getting data from a table

You can get data from MSSQL table in pandas dataframe.

m.execute_to_df(
    '''select * from simple_'''
)

Getting a connector to the database.

It can be used as you need.

m.get_uri()

What does the connector look like

Engine(Engine(MSSQL+pyMSSQL://root:***@127.0.0.1:3/sys))

Delete our simple_ table

You can drop any MSSQL table

m.execute_script('DROP TABLE simple_')