简体   繁体   English

Databricks SQL 连接器用于 Python - 如何执行多个查询?

[英]Databricks SQL Connector for Python - How to execute Multiple Queries?

I can successfully execute each query individually, and can run multiple in the databricks environment, However I can not get it to work for a multi-query statement through Databricks SQL Connector for Python.我可以单独成功地执行每个查询,并且可以在 databricks 环境中运行多个,但是我无法通过 Databricks SQL Connector for Python 使其适用于多查询语句。 Piece of the python below;下面的 python 片;

query = '''
Drop table if exists Table_Name

create table Table_Name (
Field1 String,
Field2 Int
 )
 '''
cursor.execute(query)

Which will give the following error;这将给出以下错误;

mismatched input 'create' expecting不匹配的输入“创建”期望

Are Multi-query statements possible, if so what am I missing?是否可以使用多查询语句,如果可以,我错过了什么?

missing ;失踪; after each statement maybe?在每个声明之后?

query = '''
Drop table if exists Table_Name;

create table Table_Name (
Field1 String,
Field2 Int
 );
 '''
cursor.execute(query)

Please add semicolon after each query:请在每个查询后添加分号:

Drop table if exists Table_Name;如果存在 Table_Name,则删除表;

create table Table_Name ( Field1 String, Field2 Int );创建表 Table_Name ( Field1 String, Field2 Int );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM