Friday, November 12, 2010

Finding The .SQL Mime Type SQL Server Mime Type

OMG! Why are some things so much more difficult than they need to be? I am creating a database application to make my life simpler. The application allows you to enter class file information once and then the application automatically, or should I say automagically, creates the class .cs file, Fluent NHibernate mapping files in your choice of AutoMap or ClassMap files (AutoMap and overrides are my preference) and the database .sql script. Creating the files and saving them to the database is simple. The problem came when I needed to download the files from the database. The system was adding a .txt file to the end of the file - Example: FileName.sql.txt. This was making me very sad.

I decided to get the actual mime type for a sql file so that the file would download appropriately without adding .txt to the file. Well you would think that I was trying to find how to get into Fort Knox or something. The general consensus is that most people just want to use text/plain. Not I said the mouse! Well I decided to use something I had used before - the Gnome Mime Type database. This database had allowed me to find a mime type that worked properly with some other Microsoft files that I was saving and retrieving from a database (for example, the mime type for a .cs file in the Gnome library is text/c-sharp and it works perfectly). Sooooo back to my good old friend.

The mime type for a .sql file is text/x-sql. The Gnome mime library is pretty extensive. The goal is to be a resource and standard way of using and finding mime types.

This is a simple thing, but since Google wasn't the easiest resource for finding the mime type for .sql files, I thought you might find this useful.

PROBLEM:
What is the .sql mime type? Where can I find the .sql mime type? Should I use text/plain or another mime type for .sql files?

SOLUTION:
You can use text/x-sql and you can use the Gnome library to find out more mime types as needed.

Smooches,

Kila Morton