0

I'm trying to test the jdbc connection by querying our Customer netsuite table with spark jdbc in Databricks. I've added the .jar file to the cluster and trying to run the below. I tried with the schema in the query also... but our schema is "FL - Accounting" so maybe I didn't add it correctly?

jdbc_url = "jdbc:ns://xxxx.connect.api.netsuite.com:1708;ServerDataSource=NetSuite2.com;Encrypted=1;NegotiateSSLClose=false;CustomProperties=(AccountID=xxxx;RoleID=xxx)"


netsuite_query= f"""
(
SELECT TOP 10 * FROM Customer
) AS t
"""

try:
    print(f"Attempting to read using the query: {netsuite_query}")


df = spark.read \
.format("jdbc") \
.option("url", jdbc_url) \
.option("dbtable", netsuite_query) \
.option("user", "xxxx") \
.option("password", "xxx") \
.option("driver", "com.netsuite.jdbc.openaccess.OpenAccessDriver") \
.load()

display(df)

except Exception as e:
    raise e
  • Note I also tried with:

\

.option("query", netsuite_query) \
.option("dbtable", "oa_tables") \
8
  • try just SELECT TOP 10 * FROM Customer perhaps Commented Jun 26 at 20:45
  • Please provide the full error. Also, is TOP 10 actually valid syntax in NetSuite? Commented Jun 28 at 11:11
  • @siggemannen - I tried that also, I also tried with SELECT * FROM oa_tables; but same error Commented Jun 30 at 9:37
  • @MarkRotteveel - that's the entire error message I see unfortunately. Commented Jun 30 at 9:37
  • did you remove the wrapping: ( ) around the statement? Commented Jun 30 at 9:41

1 Answer 1

0

I took a closer look and it looks like the issue was happening for me at the display() part, so I removed that and saved the results to a csv and that worked!

        .load() \
        .write \
        .format("csv") \
        .option("header", "true") \
        .mode("overwrite") \
        .save(output_path)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.