Wednesday, April 05, 2006

pymssql - example script

This is a simple script to test a connection of pymssql.
It's easy, but I always forgot. It seems that I'm getting old. lol.

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymssql
>>> con = pymssql.connect(user="sa", password="bedjo", host="192.168.31.31", database="bedjo");
>>> cur = con.cursor();
>>> cur.execute("select * from m_site");
>>> print cur.rowcount;
>>> print cur.fetchall();
>>> cur.execute("insert into log_message values ('succes') ");
>>> con.commit();
>>> con.close();

Thats all, the simple things to do.

1 comment:

Swajak said...

I just wanted to say thanks for the example! Short, and quick to the point :)