Publisher's Synopsis
This book is about the recipes on PYODBC and SQLAlchemy to work with Microsoft SQL Server databases and its data in table.
Here are various recipes covering almost all the activities that are required by a Data Engineer, Scientist, Analyst or Python Developer. The book is divided into two sections,- PYODBC recipes
- SQLAlchemy recipies
After that there may be one or more approaches or ways that we have implemented in that topic. The book covers the over the following topics and recipes, Introduction to Python, SQL, VS Code, Python extensions, pyodbc, sqlalchemy, odbc driver
Guidance on installing python, VS code, pyodbc, sqlalchemy Setting up database, tables, and creating stored procedures used in this book. Then code recipes are divided into 2 parts,
- pyodbc recipes
- sqlalchemy recipes
PYODBC connection, cursor, commit, execute, objects & methods
CRUD Operations (insert, update, delete, and select/read data) with various approaches
Handling parameters of parameterized SQL queries & USPs
Handling SQL 'IN' operator parameters
Handling multiple resultsets of USP
How to handle multiple parameters
Different approaches to create and pass parameters
Cursor functions fetchall(), fetchone(), fetchval(), fetchmany(), rowcount etc.
Accessing rows & columns of a result set
Working with row by row or batch of rows
pandas methods read_sql(), read_sql_query(), read_table()
Calling stored procedures with & without parameters
Working with multiple databases, and looping through list of databases
Using 'with' statement
SQLALCHEMY core data api
SQLALCHEMY engine url, engine, connection, execute, cursor etc.
SQLALCHEMY exec_driver_sql(), raw_connection(), etc.
Working with pandas dataframe to insert & update multiple records And many more important topics in pyodbc, and sqlalchemy