Open aborruso opened 1 year ago
Hi @aborruso,
I think it will be a nice feature if we have (so I'm marking it as a feature request):
$ frictionless describe table.csv --sql
Currently, in the latest versions we're working on a static mapper:
import sqlalchemy as sa
from frictionless import Schema, formats
engine = sa.create_engine("sqlite://")
mapper = formats.sql.SqlMapper(engine)
schema = Schema.describe("data/table.csv")
table = mapper.write_schema(schema, table_name="table")
# here we have sqlalchemy.Table
print(repr(table))
@shashigharti @aivuk I didn't manage to get compiled "CREATE" statement -- maybe you know how to do so?
CreateTable
prints the 'CREATE" statement
import sqlalchemy as sa
from frictionless import Schema, formats
from sqlalchemy.schema import CreateTable
engine = sa.create_engine("sqlite://")
mapper = formats.sql.SqlMapper(engine)
schema = Schema.describe("python/countries.csv")
print("Schema")
print(schema)
table = mapper.write_schema(schema, table_name="table")
# here we have sqlalchemy.Table
print(repr(table))
# create statement
print(CreateTable(table))
Thanks @shashigharti! :tada:
Thank you very much @shashigharti
For me it would be great to have this option available in the cli.
Thank you again and let me know if I have to close the issue
Let's keep this issue as a feature request I've changed the title
Hi, the frictionless describe output is one of the best tool to have CSV automatic inferencing of field types.
Is there a way to use frictionless to create a sql schema output?
If it's not possible via cli, is it possible via Python?
Thank you