Skip to content

Instantly share code, notes, and snippets.

Avatar

radityo radityopw

View GitHub Profile
@radityopw
radityopw / CommandResult.java
Created Oct 15, 2021
membuat db sederhana part 2
View CommandResult.java
package com.radityopw.simpledb;
public class CommandResult{
public static final int OK = 1;
public static final int ERROR = 2;
public static final int EXIT = 3;
public int status = CommandResult.OK;
public String message = "";
@radityopw
radityopw / .gitignore
Created Oct 15, 2021
membuat DBMS sederhana day 1
View .gitignore
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
View trigger_readonly_table_create.sql
CREATE TRIGGER <schema>.<table_name>_read_only_events ON <schema>.<table_name>
INSTEAD OF INSERT,
UPDATE,
DELETE
AS
BEGIN
RAISERROR( 'table is read only.', 16, 1 )
ROLLBACK TRANSACTION
END
@radityopw
radityopw / String or binary data would be truncated.sql
Last active Feb 19, 2021
sql script to investigate String or binary data would be truncated
View String or binary data would be truncated.sql
;WITH CTE_Dev
AS (
SELECT C.column_id
,ColumnName = C.NAME
,C.max_length
,C.user_type_id
,C.precision
,C.scale
,DataTypeName = T.NAME
FROM sys.columns C
@radityopw
radityopw / catatan_excel_dengan_win32.py
Created Dec 25, 2020
membaca, menulis excel dari python menggunaan win32 py
View catatan_excel_dengan_win32.py
# install library
pip install pywin32
# import komponen
import win32com.client
# untuk membuka excel
xl = win32com.client.Dispatch('Excel.Application')
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`);