File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "cells" : [
3+ {
4+ "cell_type" : " markdown" ,
5+ "id" : " 158965c7" ,
6+ "metadata" : {},
7+ "source" : [
8+ " MSSQL with Python"
9+ ]
10+ },
11+ {
12+ "cell_type" : " code" ,
13+ "execution_count" : null ,
14+ "id" : " ce2e4a03" ,
15+ "metadata" : {
16+ "vscode" : {
17+ "languageId" : " plaintext"
18+ }
19+ },
20+ "outputs" : [],
21+ "source" : [
22+ " !pip install mssql-python"
23+ ]
24+ },
25+ {
26+ "cell_type" : " code" ,
27+ "execution_count" : null ,
28+ "id" : " 1c31f2f3" ,
29+ "metadata" : {
30+ "vscode" : {
31+ "languageId" : " plaintext"
32+ }
33+ },
34+ "outputs" : [],
35+ "source" : [
36+ " import mssql_python\n " ,
37+ " \n " ,
38+ " # Establish a connection\n " ,
39+ " # Specify connection string\n " ,
40+ " connection_string = \" YOUR_CONNECTION_STRING\"\n " ,
41+ " # sample connection\n " ,
42+ " # SERVER=<your_server_name>;DATABASE=<your_database_name>;UID=<your_user_name>;PWD=<your_password>;Encrypt=yes;\n " ,
43+ " connection = mssql_python.connect(connection_string)\n " ,
44+ " \n " ,
45+ " # Execute a query\n " ,
46+ " cursor = connection.cursor()\n " ,
47+ " cursor.execute(\" SELECT * from customer\" )\n " ,
48+ " rows = cursor.fetchall()\n " ,
49+ " \n " ,
50+ " for row in rows:\n " ,
51+ " print(row)\n " ,
52+ " \n " ,
53+ " # Close the connection\n " ,
54+ " connection.close()"
55+ ]
56+ }
57+ ],
58+ "metadata" : {
59+ "language_info" : {
60+ "name" : " python"
61+ }
62+ },
63+ "nbformat" : 4 ,
64+ "nbformat_minor" : 5
65+ }
You can’t perform that action at this time.
0 commit comments