generated from pamelafox/sqlalchemy-sqlite-playground
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import os | ||
|
||
from azure.identity import DefaultAzureCredential | ||
|
||
|
||
def get_conn(): | ||
azure_credential = DefaultAzureCredential() | ||
token = azure_credential.get_token("https://ossrdbms-aad.database.windows.net") | ||
return token.token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import os | ||
|
||
|
||
from dotenv import load_dotenv | ||
import psycopg2 | ||
|
||
from dotenv import load_dotenv | ||
|
||
# Connect to the database | ||
load_dotenv(".env") | ||
load_dotenv(".env", override=True) | ||
DBUSER = os.environ["DBUSER"] | ||
DBPASS = os.environ["DBPASS"] | ||
#azure_credential = DefaultAzureCredential() | ||
#DBPASS = azure_credential.get_token("https://ossrdbms-aad.database.windows.net") | ||
DBHOST = os.environ["DBHOST"] | ||
DBNAME = os.environ["DBNAME"] | ||
|
||
conn = psycopg2.connect(database=DBNAME, user=DBUSER, password=DBPASS, host=DBHOST) | ||
cur = conn.cursor() | ||
cur.execute("DROP TABLE IF EXISTS restaurants") | ||
cur.execute("CREATE TABLE restaurants (id SERIAL PRIMARY KEY,name VARCHAR(255) NOT NULL)") | ||
cur.execute("INSERT INTO restaurants (id, name) VALUES ('3', 'test')") | ||
conn.commit() | ||
cur.close() | ||
cur.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[tool.ruff] | ||
line-length = 120 | ||
target-version = "py311" | ||
select = ["E", "F", "I", "UP"] | ||
ignore = ["D203"] | ||
show-source = true | ||
|
||
[tool.black] | ||
line-length = 120 | ||
target-version = ["py311"] |