Skip to main content

This is a wrapper around ln2sql by Jeremy Ferrero for convenient use

Project description

ln2sqlmodule

This is an adoption of the awesome ln2sql by Jérémy Ferrero as a python module so that people can easily use it to create some awesome things !

Things added in ln2sqlmodule :

  • API for getting WHERE queries with LIKE and '%'
  • INNER JOIN working correctly with FOREIGN KEY
  • PRIMARY KEY and FOREIGN KEY detection from ALTER STATEMENT
  • Value extraction from natural language

INSTALLATION

pip install ln2sqlmodule
import ln2sqlmodule

USAGE

getSql(query, sqlDump[, outputFile])

  • ln2sqlmodule.getSql(query, sqlDump[, outputFile])

returns SQL query from natural language query

outputFile Schema

    Parameters :
		query           :    query in natural language
		sqlDump         :    path to sql dump file    
		[outputFile]    :    path to file to output SQL query in json       

	returns : 
		SQL query string

	Example:
		ln2sqlmodule.getSql("get name of all emp","./emp.sql")
		-> SELECT name FROM  emp

getSql_like(query, sqlDump[, outputFile])**

returns SQL query from natural language with LIKE with % in WHERE clause

outputFile Schema

    Parameters :
		query        :    query in natural language
		sqlDump      :    path to sql dump file
		[outputFile] :    path to file to output SQL query in json   

	returns : 
		SQL query string with LIKE

	Example:
		ln2sqlmodule.getSql("all data for emp where name is rupinder","./emp.sql")
		-> SELECT * FROM  emp WHERE name LIKE '%rupinder%'

		ln2sqlmodule.getSql("all data for emp where name is 'abc xyz'","./emp.sql")
		-> SELECT * FROM  emp WHERE name LIKE '%abc%xyz'

outputFile Schema

{
	"select": {
		"column": "",
		"type": ""
	},
	"from": {
		"table": ""
	},
	"join": {
	},
	"where": {
	},
	"group_by": {
	},
	"order_by": {
	}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ln2sqlmodule-1.0.0.tar.gz (15.5 kB view hashes)

Uploaded Source

Built Distribution

ln2sqlmodule-1.0.0-py2-none-any.whl (30.6 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page