This document provides guidelines for maintaining high-quality Python code. These rules MUST be followed by all AI coding agents and contributors.
All code you write MUST be fully optimized.
"Fully optimized" includes:
| ## NOTE: editing your dataset via the XMLA endpoint will prevent you from downloading it | |
| ## so make sure you have a backup of the original pbix file | |
| $clientID = '<your-clientId>' | |
| $clientSecret = '<your-client-secret>' | |
| $tenantID = '<your-teantId>' | |
| $workspaceName = 'Xmla%20Test' | |
| $datasetName = 'Role Test' | |
| $roleName = 'DynamicRole' |
| { | |
| "inputs": { | |
| "host": { | |
| "connectionName": "shared_sharepointonline", | |
| "operationId": "HttpRequest", | |
| "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline" | |
| }, | |
| "parameters": { | |
| "dataset": "https://forms.office.com", | |
| "parameters/method": "GET", |
| #!/usr/bin/env python | |
| # Get all the database objects and permissions. | |
| # Can be used after running snowflake_roles.py to create the required roles | |
| # 2018-10-23 jfrink added ddl for roles, modified connection parameters | |
| # 2019-01-15 jfrink added Roles and permissions report by object. | |
| # 2019-03-07 jfrink added extract script to create a dump of all the tables to a stage | |
| # and also the corresponding script to load all the data. | |
| # Converted show tables over to using information schema for cases greater then 10k rows. | |
| # Converted show views over to using information schema for cases greater then 10k rows. |
| Power BI Connectionstring to dataset without premium. Works with Free tier. | |
| Use `Microsoft.AnalysisServices.AdomdClient.AdomdConnection` | |
| `Data Source=pbiazure://analysis.windows.net:443/powerbi/api;Initial Catalog=<VirtualServerName>-<DatasetId>;Location="<PowerBIClusterUrl>/xmla?vs=<VirtualServerName>&db=<DatasetId>";Password="<PowerBIAccessToken>";Provider=PBIDATASET` | |
| VirtualServerName = `sobe_wowvirtualserver` or `sobe_onpremisevirtualserver` | |
| PowerBIClusterUrl = e.g. `https://wabi-west-europe-d-primary-redirect.analysis.windows.net` and see JS variable in PowerBI portal. | |
| DatasetId = See URL in PowerBI portal when looking at dataset options. | |
| PowerBIAccessToken = Example see JS variable in PowerBI portal. |
| ///* | |
| let func = | |
| (ParChTable as table, | |
| ChildKey as text, | |
| ParentKey as text, | |
| LevelColumnName as text) => | |
| //*/ | |
| let |
| //list available DMVs | |
| Select * from $SYSTEM.DBSCHEMA_TABLES where table_type = 'Schema' order by table_name | |
| //Useful DMVs for 2016 SSAS Tabular Models | |
| Select * from $SYSTEM.TMSCHEMA_ATTRIBUTE_HIERARCHY_STORAGES //distinct data count for each column | |
| Select * from $SYSTEM.TMSCHEMA_ATTRIBUTE_HIERARCHIES //ties hierarchy id to column | |
| SELECT * from $SYSTEM.TMSCHEMA_COLUMN_STORAGES //has order by column, row count is inaccurate | |
| Select * from $SYSTEM.TMSCHEMA_COLUMNS //column name, ID for table, data type, category, hidden, iskey, isunique, is nullable, summarize by, expression for calc columns, hierarchy id, refresh time, modify time. source provider type, display folder | |
| SELECT * from $SYSTEM.TMSCHEMA_DATA_SOURCES //connection string, account, impersonation mode, name | |
| Select * from $SYSTEM.TMSCHEMA_HIERARCHIES //hierarchy name, display folder |
| declare @tableName varchar(200) | |
| declare @columnName varchar(200) | |
| declare @nullable varchar(50) | |
| declare @datatype varchar(50) | |
| declare @maxlen int | |
| declare @sType varchar(50) | |
| declare @sProperty varchar(200) | |
| DECLARE table_cursor CURSOR FOR |
| from datetime import datetime | |
| from sqlalchemy import Column, Integer, DateTime, ForeignKey | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.ext.declarative import declared_attr | |
| from flask_security import current_user | |
| class AuditMixin(object): | |
| created_at = Column(DateTime, default=datetime.now) | |
| updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now) |
| import sqlalchemy as sa | |
| import sqlalchemy.orm as orm | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.ext.declarative import declared_attr | |
| from sqlalchemy.orm import scoped_session, sessionmaker | |
| DBSession = scoped_session(sessionmaker()) | |
| class BaseMixin(object): | |
| query = DBSession.query_property() | |
| id = sa.Column(sa.Integer, primary_key=True) |