When using java, prepared statement can insert string with single quote easily. I tried to achieve the same thing with python. I finally got prepared statement using cx_Oracle, but it was very ugly and unintuitive.
I tried this task with postgresql hoping for a better solution. Things were worse in Postgres. I knew that my favorite psycopg2 does not support prepared statement, yet. But, the rest of the drivers, such as pypgsql and all others that I have researched, were in the same status.
Anyway, I found this this link:
http://catherinedevlin.blogspot.com/2005_07_01_archive.html
Oracle had a different idea. Different quote operator. q'| |'. Like python block quote('''), it relieves single quote when wrapped around it.
Insert into tbl(txt) values ( q'|Hello world's geeks.|' );
Thursday, June 28, 2007
Coming back to work after the vacation
Thanks to my second son, Jaron, I had a wonderful vacation. It was the best and the busiest vacation that I had. Actually, I came back early this week. I already spent three business days in my office. I was afraid of the big eagerness of leaving my office, but that wasn't too much bad. I sit down nicely and processed pending jobs.
Programming skills needed time to get up to speed. English was troubled for a while, Korean much more fluent :) I hope my kids pick up Korean first.
Now, the good days of vacation is over and the life resumes with an additional responsibility. I don't mind, though. Maybe, Jake will object?
Programming skills needed time to get up to speed. English was troubled for a while, Korean much more fluent :) I hope my kids pick up Korean first.
Now, the good days of vacation is over and the life resumes with an additional responsibility. I don't mind, though. Maybe, Jake will object?
Thursday, June 7, 2007
my new family.
On May 26th, 2007, my second son, Jaron, was born. Having paternity leave now. Yeah~~~. It was the same hospital, the same level, but the room was the other side of hall as we were there two years ago. Funny thing is that not my wife but I am having emotional fluctuation mostly toward happy side with a little bit of tears ( Shame on ME, a man with tear! )
Anyway, his first image brought a deja-vu. He looks exactly the same with my first one, Jake. When getting a chance, I want to show pictures of my sons side by side. My wife and I took a picture on purpose when we put Jaron in the baby basket for the first time. We successfully took the same angle, the same pause, but in different clothes two years ago as we took Jake. If somebody sees these pictures side by side, 'Hmmmm,... Why did you change baby's clothes on discharge from the hospital? Were you guys bored enough?'
Anyway, his first image brought a deja-vu. He looks exactly the same with my first one, Jake. When getting a chance, I want to show pictures of my sons side by side. My wife and I took a picture on purpose when we put Jaron in the baby basket for the first time. We successfully took the same angle, the same pause, but in different clothes two years ago as we took Jake. If somebody sees these pictures side by side, 'Hmmmm,... Why did you change baby's clothes on discharge from the hospital? Were you guys bored enough?'
Wednesday, May 23, 2007
Python twisted part 2
Several days ago, I have introduced python twisted (and I just mentioned perl POE. ) The application that I have created on that day needed a new feature, Control Port. It wasn't a big deal. I opened another port with separate protocol that I have defined and spit back CSV of requested report. CSV can be easily turned into a graph. Supporting XML seems like too much for this but can be done easily thanks to BeautifulSoup. I also supported 'stop the daemon' for fun. Took me just 1 hour !!
The beauty of this was that control part seamlessly communicates with collectors because they are running under the same application. At the same time, I do NOT need to think about Threading and locking. How nice it is !!
The beauty of this was that control part seamlessly communicates with collectors because they are running under the same application. At the same time, I do NOT need to think about Threading and locking. How nice it is !!
Thursday, May 17, 2007
python twisted
It is just over 1 year that I have used twisted. I actually used Perl POE before I used twisted. It does not matter which one is chosen. Python users will use twisted, Perl users will use POE. They both are very useful. Personally, I prefer twisted simply because I am a python user.
These are called asynchronous high level network framework. Sometimes word 'abstracted' is attached in introductory contents.
First thing we have to focus is what it is. 'Abstracted' or 'High level' can be best described as 'Protocol Implemented'. I do not have to worry about protocol specifics. I just call methods from objects instantiated from twisted.SomePackage. And asynchronous means, not synchronous. Then, someone may ask what is synchronous? Let's simplify that 'synchronous' is similar way to have conversation between human beings. One person asks, and wait until the other responses. Peers don't speak at the same time. In asynch mode, they do. More in detail can be found in Unix Network Programming ( a.k.a UNP ). There are more in detail about asynchronous communication (non-blocking, signal driven, etc.) I recommend reading UNP for network programmers. Chapters about Async-communication was the best.
With these network frameworks, any network driven application can be very simplified in terms of number of lines of code. Especially, server applications processing custom protocols are very simplified. Buffer handling/IO handling is almost trivial and the performance is even faster thanks to async IO's better utilization of bandwidth.
This morning, I have written another network server processing message from various servers. The key word is 'This Morning'. That's right. I wrote this in low degree of hours. Actually, in 2 hours. I just process the message and stuff into sqlite3, and my life goes on. If I have to write the same code in C, it should take up at least 1 day. :)
These are called asynchronous high level network framework. Sometimes word 'abstracted' is attached in introductory contents.
First thing we have to focus is what it is. 'Abstracted' or 'High level' can be best described as 'Protocol Implemented'. I do not have to worry about protocol specifics. I just call methods from objects instantiated from twisted.SomePackage. And asynchronous means, not synchronous. Then, someone may ask what is synchronous? Let's simplify that 'synchronous' is similar way to have conversation between human beings. One person asks, and wait until the other responses. Peers don't speak at the same time. In asynch mode, they do. More in detail can be found in Unix Network Programming ( a.k.a UNP ). There are more in detail about asynchronous communication (non-blocking, signal driven, etc.) I recommend reading UNP for network programmers. Chapters about Async-communication was the best.
With these network frameworks, any network driven application can be very simplified in terms of number of lines of code. Especially, server applications processing custom protocols are very simplified. Buffer handling/IO handling is almost trivial and the performance is even faster thanks to async IO's better utilization of bandwidth.
This morning, I have written another network server processing message from various servers. The key word is 'This Morning'. That's right. I wrote this in low degree of hours. Actually, in 2 hours. I just process the message and stuff into sqlite3, and my life goes on. If I have to write the same code in C, it should take up at least 1 day. :)
Tuesday, May 8, 2007
Stripping HTML tag
I had to write a module to 'word count' a web page. This required to strip the HTML tags out of the url read. I quickly googled, but I felt that this kind of easy problem doesn't even need googling. So, I came up with simple solution.
This is very rough test code written using BeautifulSoup.
http://lucky.umd.edu/code/strip-htmltag.py
This is very rough test code written using BeautifulSoup.
http://lucky.umd.edu/code/strip-htmltag.py
Tuesday, May 1, 2007
My tool set
1. springnote.com and basKet:
These are my note takers. I normally use springnote.com because of accessibility. 'Hey, it is another Korean website.' Sorry :)
2. Google tool set:
I do not have to explain what are google tool set. Google always brings one of the essential tools for life. Beginning with gmail, there are calendar, map, earth, doc, personalized google portlets, blog(Of course!), analytics, talk, and most infamous Google SEARCH! I can not live without google.
3. flickr, kflickr, flickrapi(by Beej)
This is one that google couldn't rule. I tried to use picasa from google, flickr really ruled. My pictures and my family's pictures are posted there.
4. kdissert, vym for brain storming.
There is a project called 'freemind'. I used to use it but after I migrated to KDE from gnome, I used kdissert instead. vym helps kdissert. 'freemind' is not a bad tool, but I like simplicity to use in kdissert.
5. bloglines for news read
I use this not only for news reader, but also for good article keeper with 'important' tag. That is very useful.
6. KDE desktop with Gentoo, Ubuntu
When using linux, I chose KDE for my desktop. I started with bare gnome about 7-8 years ago when I first used Linux ( At that time, I just started computer science degree ). Then I moved to blackbox, later it became fluxbox. Then, I moved back to gnome after CPU hits GHz and 512 Mb became general PC memory size. And then, I settled in KDE. KDE is just very easy and well-balanced desktop environment.
7. keychain for ssh-agent
Because of my work, I have to jump from machines to machines. Without this, typing up my password everytime should not be imagined!!
8. Other utilities for fun
Such as amaroK, mplayer, etc.
These are my note takers. I normally use springnote.com because of accessibility. 'Hey, it is another Korean website.' Sorry :)
2. Google tool set:
I do not have to explain what are google tool set. Google always brings one of the essential tools for life. Beginning with gmail, there are calendar, map, earth, doc, personalized google portlets, blog(Of course!), analytics, talk, and most infamous Google SEARCH! I can not live without google.
3. flickr, kflickr, flickrapi(by Beej)
This is one that google couldn't rule. I tried to use picasa from google, flickr really ruled. My pictures and my family's pictures are posted there.
4. kdissert, vym for brain storming.
There is a project called 'freemind'. I used to use it but after I migrated to KDE from gnome, I used kdissert instead. vym helps kdissert. 'freemind' is not a bad tool, but I like simplicity to use in kdissert.
5. bloglines for news read
I use this not only for news reader, but also for good article keeper with 'important' tag. That is very useful.
6. KDE desktop with Gentoo, Ubuntu
When using linux, I chose KDE for my desktop. I started with bare gnome about 7-8 years ago when I first used Linux ( At that time, I just started computer science degree ). Then I moved to blackbox, later it became fluxbox. Then, I moved back to gnome after CPU hits GHz and 512 Mb became general PC memory size. And then, I settled in KDE. KDE is just very easy and well-balanced desktop environment.
7. keychain for ssh-agent
Because of my work, I have to jump from machines to machines. Without this, typing up my password everytime should not be imagined!!
8. Other utilities for fun
Such as amaroK, mplayer, etc.
Subscribe to:
Posts (Atom)
