$ pip install click requests
$ python query_export.py --redash-url "https://app.redash.io/" --api-key ""
| import re | |
| class BabyShark: | |
| def __init__(self): | |
| self.generation = re.findall('[A-Z][^A-Z]*', self.__class__.__name__)[0] | |
| self.entities = ' '.join(re.findall('[A-Z][^A-Z]*', self.__class__.__name__)) | |
| self.doo_line = ', '+ 4 * " Doo" | |
| self.song_line = self.entities + self.doo_line | |
| def swim(self): | |
| print("{0!r} is swimming".format(str(self.entities))) |
| # Import necessary package | |
| import wget | |
| import os | |
| import json | |
| from multiprocessing import Pool | |
| import time | |
| start_time = time.time() | |
| # Initialize variable | |
| root_store = '/content/gdrive/My Drive/Weather_Forecast_Data_Gathering/' # Change to local machine directory |
| # Reference: | |
| # - https://stackoverflow.com/questions/32468402/how-to-explode-a-list-inside-a-dataframe-cell-into-separate-rows | |
| # - Update 2019-07: | |
| # https://github.com/pandas-dev/pandas/pull/27267 | |
| # https://stackoverflow.com/questions/53218931/how-to-unnest-explode-a-column-in-a-pandas-dataframe | |
| # https://mikulskibartosz.name/how-to-split-a-list-inside-a-dataframe-cell-into-rows-in-pandas-9849d8ff2401 | |
| import pandas as pd | |
| generic_dataframe = pd.read_csv("example.csv") |
Superset is based on Flask App Builder (FAB). Hence, certain model can be manipulated via Flask REST API. Further information about the API can be found in the official Flask App Builder documentation here
This noted was aspired from the Issue #4708
Login to API required before usages of any the API endpoint at /api/v1/security/login.
| """Direct Google Sheets Manipulation trial.""" | |
| from predictorcls import Predictor | |
| from oauth2client.service_account import ServiceAccountCredentials | |
| import gspread | |
| # import time | |
| # import random | |
| scope = ['https://spreadsheets.google.com/feeds', | |
| 'https://www.googleapis.com/auth/drive'] |
| # To dump a database into a custom-format archive file | |
| pg_dump -h <origin_postgres_host> \ | |
| -p <origin_port> \ | |
| -d <origin_postgres_db> \ | |
| -U <username_origin_postgres_rds_db> \ | |
| -W -Fc > <pg_dump_file>.psql | |
| # To restore a database into a custom-format archive file with no owner: | |
| pg_restore -h <target_postgres_host> \ | |
| -U <username_target_postgres_db> \ |
| import re, fileinput | |
| print('SET FOREIGN_KEY_CHECKS=0;') | |
| def main(): | |
| for line in fileinput.input(): | |
| process = False | |
| for nope in ('BEGIN TRANSACTION','COMMIT', | |
| 'sqlite_sequence','CREATE UNIQUE INDEX'): | |
| if nope in line: break |
| # Detect Lock | |
| select a.txn_owner, a.txn_db, a.xid, a.pid, a.txn_start, a.lock_mode, a.relation as table_id,nvl(trim(c."name"),d.relname) as tablename, a.granted,b.pid as blocking_pid ,datediff(s,a.txn_start,getdate())/86400||' days '||datediff(s,a.txn_start,getdate())%86400/3600||' hrs '||datediff(s,a.txn_start,getdate())%3600/60||' mins '||datediff(s,a.txn_start,getdate())%60||' secs' as txn_duration | |
| from svv_transactions a | |
| left join (select pid,relation,granted from pg_locks group by 1,2,3) b | |
| on a.relation=b.relation and a.granted='f' and b.granted='t' | |
| left join (select * from stv_tbl_perm where slice=0) c | |
| on a.relation=c.id | |
| left join pg_class d on a.relation=d.oid | |
| where a.relation is not null AND a.txn_owner='<db_username>'; |