Creating schema.ini with gsqlcmd

Creating schema.ini with gsqlcmd

Microsoft ODBC and OLE DB text drivers require a section in the schema.ini files to use columns.

For example, the following command does not require the schema.ini file:

gsqlcmd exec aapl.csv "SELECT * FROM aapl.csv"

However, the next command does:

gsqlcmd exec aapl.csv "SELECT symbol, time, [close] FROM aapl.csv"

gsqlcmd creates the required sections for SELECT commands in the exec mode automatically.

You can create such sections using the make-ini mode.

For example:

gsqlcmd make-ini aapl.csv schema.ini

Here is a generated content of the schema.ini file:

[aapl.csv]
ColNameHeader=True
Format=Delimited(;)
MaxScanRows=100
CharacterSet=ANSI
Col1=symbol Text
Col2=time DateTime(yyyy-MM-dd)
Col3=open Double
Col4=high Double
Col5=low Double
Col6=close Double
Col7=volume Integer

If you created a format file to rename column names, use it with the /formatFile option.

For example:

gsqlcmd make-ini aapl.csv schema.ini /formatFile=yahoo1m.fmt