Package: databricks-sql
Databricks SQLDatabricks SQL framework, easy to learn, fast to code, ready for production.Installation$pipinstalldatabricks-sqlConfigurationfromdatabricks_sql.clientimportConfigurationCONFIGURATION=Configuration.instance(access_token="",command_directory="",http_path="",server_hostname="",)UsageDatabricks SQL usage description:DeleteDelete with wherefromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.delete("catalog.schema.table").where("id","994238a4-8c18-436a-8c06-29ec89c4c056").execute())Delete with where conditionfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.delete("catalog.schema.table").where("description","%Databricks%",operator="LIKE").execute())Executefromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.execute("""CREATE TABLE IF NOT EXISTS catalog.schema.table (id STRING NOT NULL,name STRING NOT NULL,description STRING,CONSTRAINT table_primary_key PRIMARY KEY(id)) USING DELTA""",parameters=None,skip_load=True,))Insertfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.insert("catalog.schema.table").set("id","994238a4-8c18-436a-8c06-29ec89c4c056").set("name","Name").set("description","Description").execute())PagingPaging with where conditionfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.select("catalog.schema.table").fields("id","name","description").where("name","%Databricks%",operator="LIKE").order_by("id").paging(0,10))Paging without where conditionfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.select("catalog.schema.table").paging(0,10))SelectFetch allfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.select("catalog.schema.table").execute().fetch_all())Fetch manyfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.select("catalog.schema.table").execute().fetch_many(1))Fetch onefromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.select("catalog.schema.table").execute().fetch_one())Select by filefromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.execute("command.sql",{"id":"994238a4-8c18-436a-8c06-29ec89c4c056"}).fetch_one())Select by commandfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.execute("SELECT id, name, description FROM catalog.schema.table WHERE id =%(id)s",{"id":"994238a4-8c18-436a-8c06-29ec89c4c056"}).fetch_one())UpdateUpdate with wherefromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.update("catalog.schema.table").set("name","New Name").set("description","New Description").where("id","994238a4-8c18-436a-8c06-29ec89c4c056").execute())Update with where allfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.update("catalog.schema.table").set("name","New Name").set("description","New Description").where_all({"id":"994238a4-8c18-436a-8c06-29ec89c4c056","name":"Name","description":"Description"}).execute())Using mustacheSQLselectid,name,descriptionfromcatalog.schema.tablewhere1=1{{#id}}andid=%(id)s{{/id}}{{#name}}andnamelike%(name)s{{/name}}Select with filtersfromdatabricks_sql.clientimportDatabasewithDatabase()asconnection:(connection.execute("command.sql",parameters={"id":"994238a4-8c18-436a-8c06-29ec89c4c056","name":"Name"}).fetch_one())LicenseThis project is licensed under the terms of theApache License 2.0.