dts-sql
A simple command line tool that generates TypeScript definition (*.d.ts
) from SQL schema. Currently it only supports PostgreSQL.
Usage
usage: dts-sql DB_URI SCHEMA TABLE INTERFACE_NAME
DB_URI: Database URI
SCHEMA: Table schema
TABLE: From which table to generate the definition
INTERFACE_NAME: Interface name of the definition
Example
Assume we have had the sample tables loaded the database. We want to generate the definition for the employees
table:
dts-sql postgresql://postgres:secret@localhost:5432/postgres public employees IEmployee
will print out:
export interface IEmployee {
'emp_no': number;
'birth_date': Date;
'first_name': string;
'last_name': string;
'gender': any | null;
'hire_date': Date;
}
License
MIT. See License file.