Skip to content

Instantly share code, notes, and snippets.

Avatar

radityo radityopw

View GitHub Profile
View sqlserver_backup_db_scripts.py
import pyodbc
import time
from shutil import copy
import smtplib
import os
import datetime
def backup_db(cnxn,mode,backup_dir,secondary_backup_dirs,dbname):
backup_name = dbname+"-"+mode+" database backup"
View change_tracking_script.sql
/*
drop table #source ;
drop table #source_diff;
drop table #source_deleted;
*/
declare @last_synchronization_version bigint;
View change_tracking_ddl.sql
CREATE TABLE [dbo].[change_tracking_data](
[id] [int] IDENTITY(1,1) NOT NULL,
[nama] [varchar](50) NOT NULL,
CONSTRAINT [PK_change_tracking_data] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
View python_change_tracking_process.py
import sqlalchemy
from sqlalchemy.pool import NullPool
from sqlalchemy import text
def connect_sqlserver():
user = ""
password = ""
database = ""
View mariadb_pegawai_replicated.sql
CREATE TABLE `pegawai_replicated` (
`id` int(11) NOT NULL,
`nama` varchar(50) NOT NULL,
`jenis_kelamin` char(1) NOT NULL,
`is_deleted` tinyint(4) NOT NULL
) ENGINE=Aria DEFAULT CHARSET=utf8mb4;
ALTER TABLE `pegawai_replicated`
ADD PRIMARY KEY (`id`);
View sqlserver_change_tracking_trigger.sql
CREATE TABLE [dbo].[pegawai](
[id] [int] IDENTITY(1,1) NOT NULL,
[nama] [varchar](20) NOT NULL,
[jenis_kelamin] [char](1) NOT NULL,
[create_at] [datetime] NOT NULL,
[update_at] [datetime] NOT NULL,
CONSTRAINT [PK_pegawai] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
@radityopw
radityopw / table_to_temporal_table_sqlserver.sql
Last active Jul 20, 2020
convert ordinary sqlserver table, to temporal table
View table_to_temporal_table_sqlserver.sql
declare @table nvarchar(255)
declare @sql nvarchar(max)
-- setting table name
set @table = 'dbo.test'
-- adding starttime , endtime columns
set @sql = '
View html_1st_table_to_csv.py
from bs4 import BeautifulSoup
import requests
import pandas as pd
url = 'YOUR URL HERE'
response = requests.get(url)
soup = BeautifulSoup(response.text,'lxml')
tables = soup.find_all('table')
@radityopw
radityopw / gen_trans_log_restore.php
Last active Apr 3, 2018
script untuk generate transaction log sqlserver dari list file yang ada di folder
View gen_trans_log_restore.php
<?php
/*
asumsi adalah nama trans log adalah *.trn
asumsi lain adalah nama log file melambangkan waktu dicreate nya , nama sudah terurut
*/
$dir = $argv[1]."\\*.trn";
$dbname = $argv[2];
View curl.php
<?php
$cURL = curl_init();
$User_Agent = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31';
$cookies = 'CookieName1=Value;CookieName2=Value';
curl_setopt($cURL, CURLOPT_USERAGENT, $User_Agent);
curl_setopt($cURL, CURLOPT_COOKIE, $cookies);
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
You can’t perform that action at this time.