What version of kerberos is leopard running?  

This took a bit of googling to answer so I thought I would take a note.

Apple is not very helpful, they say I am running:

Kerberos        KfM-6.0fc5 
Kerberos Administration System  KfM-6.0fc5 

Which once tracked down, here and here, Leopard is running MIT Kerberos Version 1.6 

Finally, the prompt for all this.

Does the file exist?

July 23, 2008

 

Python 2.5 has a cool any(iterable) function.  I needed to know if a file existed somewhere in a tree of files.  With any you can write something like the following:

    dirs = os.walk(os.path.abspath(''))  
    fileExists = any('testfile.txt' in x[2] for x in dirs)

Now the variable fileExists will be True if the file testfile.txt exists anywhere in the tree. 

two lines.  python is neat.

Connection Strings

July 10, 2008

odbc and mssql are the least documented/supported databases in nearly all open source projects.  I understand, evil empire, i get it.  So when I dig up gems after tons of googling I should write them down so …

Connection String for pyodbc, using a system DSN

"DSN=dsn_name;UID=username;PWD=passwd"

Connection String for sqlalchemy, using a system DSN

'mssql://username:passwd@/?dsn=dsn_name'

Leave the @ symbol after the passwd and don’t use an @ symbol in your passwd (guilty). I assume the symbol is used in the parsing of the string, why I am not so sure on.

An Alchemist’s Trials

July 10, 2008

SQL Alchemy is a terrific little library.  At least I think so on days ending in p. To be quite honest the whole ORM thing frightens me a little, too many layers between where your using your data and where it is being stored. Layers are not inherently bad in my opinion but they can drive you bananas debugging problems if you don’t understand what those layers are doing. I do not understand what SQL Alchemy is doing. Hence why I am going b-a-n-a-n-as.

But when I am not using an ORM I find my self writing half assed “database managers” which have a tendency to grow over time into unwieldy beasts.  So when a new project cropped up I decided to take the plunge, find an ORM library, learn it, love it.  I shopped around in the Python world, for it was the chosen language for the new project, and SQL Alchemy’s name kept coming up. O’reilly was about to publish a book on it which for me is like the project is getting a blessing from the gods (I like books and O’reilly has cute wild life pictures on the covers).

So I hope to take down some helpful notes on alchemy related goings on so I have a reference to all this insanity.

I am using python. Hooray for new fangled scripting glory. 
My business is an mssql shop.  meh.
I set up pyodbc. I run a simple insert statement. Sql Server Profiler logs the following (among other tidbits).

declare @p1 int
set @p1=1
exec sp_prepare @p1 output,N'@P1 VARCHAR(11)',N'insert into schemax.iptable (IPAddress) values(@P1)',1
select @p1

Very simple insert me thinks.
I want to try new orm hotness that is SQL Alchemy.
Again with the very simple test. SQL Server Profiler logs the following:

declare @p1 int
set @p1=13808
exec sp_prepare @p1 output,NULL,N'',1
select @p1

See the subtle difference?

No errors are ever thrown. It runs its little heart out. But no data is every actually inserted into the database.

I loathe odbc.  

Also, if your ever perusing the sparse documentation available on pyodbc, and see all those helpful quick examples be sure to call the commit() method which they do not show or set the autocommit flag to true.

update: my woes on the sqlalchemy-devel list here.