Creating schema.ini with gsqlcmd
Microsoft ODBC and OLE DB text drivers require a section in the schema.ini file to define columns.
For instance, the following command does not need the schema.ini file:
gsqlcmd exec aapl.csv "SELECT * FROM aapl.csv"
However, the next command does require it:
gsqlcmd exec aapl.csv "SELECT symbol, time, [close] FROM aapl.csv"
In exec
mode, gsqlcmd automatically creates the necessary sections for SELECT commands.
You can also create these sections manually using the make-ini mode.
For example:
gsqlcmd make-ini aapl.csv schema.ini
Here’s an example of the generated content for 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, include it with the /formatFile option.
For example:
gsqlcmd make-ini aapl.csv schema.ini /formatFile=yahoo1m.fmt