Skip to content

Instantly share code, notes, and snippets.

@phillipsj
Created August 20, 2020 12:56
Show Gist options
  • Save phillipsj/73458ea1366b93e06c543caeea604cab to your computer and use it in GitHub Desktop.
Save phillipsj/73458ea1366b93e06c543caeea604cab to your computer and use it in GitHub Desktop.
$ python
>>> from sqlalchemy import create_engine
>>> engine = create_engine("mssql+pyodbc://sqladmin:[email protected]:1433/adventureworks?driver=ODBC+Driver+17+for+SQL+Server")
>>> con = engine.connect()
>>> rows = con.execut('SELECT TOP 10 * FROM SalesLT.ProductCategory')
>>> [print(row) for row in rows]
(1, None, 'Bikes', 'CFBDA25C-DF71-47A7-B81B-64EE161AA37C', datetime.datetime(2002, 6, 1, 0, 0))
(2, None, 'Components', 'C657828D-D808-4ABA-91A3-AF2CE02300E9', datetime.datetime(2002, 6, 1, 0, 0))
(3, None, 'Clothing', '10A7C342-CA82-48D4-8A38-46A2EB089B74', datetime.datetime(2002, 6, 1, 0, 0))
(4, None, 'Accessories', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6', datetime.datetime(2002, 6, 1, 0, 0))
(5, 1, 'Mountain Bikes', '2D364ADE-264A-433C-B092-4FCBF3804E01', datetime.datetime(2002, 6, 1, 0, 0))
(6, 1, 'Road Bikes', '000310C0-BCC8-42C4-B0C3-45AE611AF06B', datetime.datetime(2002, 6, 1, 0, 0))
(7, 1, 'Touring Bikes', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37', datetime.datetime(2002, 6, 1, 0, 0))
(8, 2, 'Handlebars', '3EF2C725-7135-4C85-9AE6-AE9A3BDD9283', datetime.datetime(2002, 6, 1, 0, 0))
(9, 2, 'Bottom Brackets', 'A9E54089-8A1E-4CF5-8646-E3801F685934', datetime.datetime(2002, 6, 1, 0, 0))
(10, 2, 'Brakes', 'D43BA4A3-EF0D-426B-90EB-4BE4547DD30C', datetime.datetime(2002, 6, 1, 0, 0))
[None, None, None, None, None, None, None, None, None, None]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment