2010-08-31

Backup Folder using Python (tarfile)

Backup folder pake scripting ? python bisa !

syntaxnya kurang lebih seperti ini 

 

#! /usr/bin/env python

#coding=utf-8

import tarfile

t = tarfile.open(name = "/home/zergling/backup.tar.gz", mode = 'w:gz')

t.add("/home/zergling/DFiles/")

t.close()   

Script diatas membackup semua file didalam folder /home/zergling.DFiles ke tar.gz

2010-08-18

[troubleshoot] Error connecting to MSSQL 2005 using python-pymssql

Pernah ketemu error seperti ini  "Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier" saat connect ke  MS SQL 2005 menggunakan Python-PyMSSQL?

Ini solusinya ... semua string mesti di cast ke  nvarchar didalam querynya...
ini kutipannya
http://pymssql.sourceforge.net/faq.php
( "It means that SQL Server is unable to send Unicode data to pymssql, because of shortcomings of DB-Library for C. You have to CAST or CONVERT the data to equivalent NVARCHAR data type, which does not exhibit this behaviour.") 

ini contohnya menggunakan DB dari SAP B1

#!/user/bin/env python

import pymssql
 
conn = pymssql.connect(host='192.168.1.9', user='sa', password='xxxxxx', database='TestDB')
cur = conn.cursor()
cur.execute(' select top 30 docnum, convert(nvarchar, cardcode) , doctotal   \
                from dbo.oinv a   ')
row = cur.fetchall()
print row()

#print row
conn.close()





Powered by ScribeFire.

2010-08-10

10 Tool Wajib di Linux versi gua

Dari pengalaman gua main dilinux (Ubuntu)  ini 10 Tool wajib yang mesti kudu ada

1. Ulipad : Text editor yang cukup handal .. buat ngoding dari ASP, T-SQL , ampe Python ... ada fungsi "Column Mode" seperti di ultraedit
2. Datastudio : Ini tools yang ga bisa lepas dari gua, dan teramat penting (soalnya udah ga ada lagi :D) , buat admin database  ( MSSQL , PostGresSQL , MySQL), dari ngoding Store procedure sampe export import data
3. TSClient + VNCViewer : Ini buat remote destkop ke server server windows.
4. TeamViewer : Buat ngeremote komputer dari rumah
5. SSH Client : buat mainin server-server Linux / atau user yang udah pake Linux
6. OpenOffice : Nyatet, corat-coret, dan bikin laporan sederhana ( dengan bantuan OO Base + Sun Report builder)
7. DownThemAll (Plugin Firefox) : Apalagi kalau bukan buat nyedot file
8. Mercurial + Google Code : buat ngoding yang serius biar ga ilang / lupa
9. Python : Untuk mempermudah administrasi lintas platform, plus ngoding ngoding ringan
10. Pidgin : Buat cuap cuap .. sms-an dan transfer data di internal dan external network



Powered by ScribeFire.