error when trying to access file on pc from H2 Console - sql

when i try to access existed file from hfu console ,shows an error up .
the error says the following:C:\Users\najla\Pictures\Screenshots
IO Exception: "IOException reading C:\Users\najla\Desktop\Data-B\titanic.csv"; SQL statement:
select *
from csvread('C:\Users\najla\Desktop\Data-B\titanic.csv') [90028-214] 90028/90028 (Hilfe)
org.h2.jdbc.JdbcSQLNonTransientException: IO Exception: "IOException reading C:\Users\najla\Desktop\Data-B\titanic.csv"; SQL statement:
select *
from csvread('C:\Users\najla\Desktop\Data-B\titanic.csv') [90028-214]
at

Related

getting error while loading data in a table using hive

Am getting error as
"analysisException: Syntax error in line 1: undefined: LOAD DATA LOCAL
INPATH'/home/cloudera...Encounttered:IDENTIFIER Expected:INPATH CAUSED
BY:Exception:Syntax error"
My code is
LOAD DATA LOCAL INPATH '/home/cloudera/UNSW_NB15.csv' OVERWRITE INTO TABLE mybigdata;

why dbt runs in cli but throws an error on cloud UI for the exact same model?

I am executing dbt run -s model_name on CLI and the task completes successfully. However, when I run the exact same command on dbt cloud, I get this error:
Syntax or semantic analysis error thrown in server while executing query.
Error message from server: org.apache.hive.service.cli.HiveSQLException:
Error running query: org.apache.spark.sql.AnalysisException: cannot
resolve '`pv.meta.uuid`' given input columns: []; line 6 pos 4;
\n'Project ['pv.meta.uuid AS page_view_uuid#249595,
'pv.user.visitorCookieId AS (80) (SQLExecDirectW)")
it looks like it fails recognizing 'pv.meta.uuid' syntax which extract data from a json format. It is not clear to me what is going on. Any thoughts? Thank you!

How to resolve an error in Importing CSV file from PostgreSQL

I want to import a CSV file to PostgreSQL.
Shown below is the syntax used to import a CSV file to a created table i.e. salary_supervisor in PostgreSQL,
COPY salary_supervisor
FROM 'X:\XX\XXX\XXX\XXX\XXX\XXX\supervisor_salaries.csv' /* File path */
WITH (FORMAT CSV, HEADER);
However, it indicates an error as shown below,
ERROR: could not open file "X:\XX\XXX\XXX\XXX\XXX\XXX\supervisor_salaries.csv" for reading: Permission denied
HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
SQL state: 42501
Since an error was shown above, the below syntax was used to import the CSV file to PostgreSQL,
\copy (Select * From salary_supervisor)
FROM 'X:\XX\XXX\XXX\XXX\XXX\XXX\supervisor_salaries.csv' /* File path */
WITH (FORMAT CSV, HEADER);
However, it also indicated a syntax error shown below,
ERROR: syntax error at or near "\"
LINE 1: \copy (Select * From salary_supervisor)
^
SQL state: 42601
Character: 1

Need to export CSV file from PSQL on Windows (psql 13) using COPY TO

I am using
\COPY
(
SELECT *
FROM person
LEFT JOIN car ON car.id=person.car_id
)
TO 'c:/Users/nick-/Downloads/results.csv'
DELIMITER ',' CSV HEADER;
and am getting the error
ERROR: syntax error at or near "TO"
LINE 6: TO 'c:/Users/nick-/Downloads/results.csv'
I've also tried COPY rather than \COPY but I get this error
ERROR: could not open file "c:/Users/nick-/Downloads/results.csv" for writing: Permission denied
HINT: COPY TO instructs the PostgreSQL server process to write a file. You may want a client-side facility such as psql's \copy.
I have tried using all of the below
c:/Users/nick-/Downloads/results.csv
c://Users//nick-//Downloads//results.csv
'c:\Users\nick-\Downloads\results.csv'
'c:\\Users\\nick-\\Downloads\\results.csv'
and none have worked.

How can I resolve an Arithmetic Overflow Error when inserting data from a CSV into a SQL Server table?

I am trying to read in a .CSV file of test results into my SQL Server Express database, and I am able to get two of the 25 rows into my database, but then it errors out with the following error:
DataError: ('22003', u'[22003] [Microsoft][ODBC SQL Server Driver][SQL
Server]Arithmetic overflow error converting varchar to data type
numeric. (8115) (SQLExecDirectW); [22003] [Microsoft][ODBC SQL Server
Driver][SQL Server]The statement has been terminated. (3621)')
It doesn't specify which field or column is causing the issue; and I have searched Google and Stack Exchange, but haven't found anything to resolve this issue. Any help would be greatly appreciated.
I am using Python 2.7, SQL Server Express, and pyodbc for the connection between the two.
Here is the code that I am trying to run:
import pyodbc
import csv
print
print("Please wait while I connect to database...")
print
# Connecting to the Database
mydb = pyodbc.connect('Driver={SQL Server};'
'Server=DESKTOP-5I015MM\SQLEXPRESS;'
'Trusted_Connection=yes;')
# Turning on autocommit
mydb.autocommit = True
# Creating a cursor object
mycursor = mydb.cursor()
mycursor.execute("USE mydatabase")
print
print("Connection to the database was successful!")
# Adding Test Results to database - Look into this...
strSQL='''INSERT INTO TestResults(datasource, modelNumber, testSequence, reportingCondition, testDate, isc, voc, imp, vmp, ff, pmp, noct)
VALUES ('SolarLabs',?,?,?,?,?,?,?,?,?,?,?)'''
#open csv file
with open('test_results_NOCT.csv','rb') as f:
csvfile= csv.reader(f)
next(csvfile)
for row in csvfile:
mycursor.execute(strSQL, row)
print
print("Test Results added successfully")
print
And here is the CSV code that I am trying to read into SQL:
Model,Test Sequence,Condition,Date,Isc,Voc,Imp,Vmp,FF,Pmp,NOCT
KUT0012,Baseline,STC,3/11/2008,5.2,44.7,4.88,35.7,75,174.3,51.9
KUT0003,Baseline,STC,3/11/2008,5.34,44.7,5.03,35.7,75.2,179.7,52.1
KUT0003,TC200,STC,5/7/2008,5.2,45.1,4.83,36.4,75.2,176.2,-
KUT0004,Baseline,STC,3/11/2008,5.21,44.8,4.91,36.1,76,177.2,51.8
KUT0004,TC200,STC,5/7/2008,5.17,45.1,4.81,36.5,75.3,175.6,-
KUT0004,Hotspot,STC,6/25/2008,5.09,45.6,4.7,37,74.9,173.7,-
KUT0001,Baseline,STC,3/11/2008,5.32,44.6,4.95,35.4,73.8,175.2,51.8
KUT0001,TC200,STC,5/7/2008,5.2,45,4.77,36.8,75.1,175.6,-
KUT0006,Baseline,STC,3/11/2008,5.35,44.4,4.95,35.8,74.5,177.2,52
KUT0006,UV,STC,6/5/2008,5.28,44.6,4.84,35.8,73.7,173.7,-
KUT0006,TC50,STC,7/4/2008,5.22,45,4.72,36.9,74.1,173.9,-
KUT0006,HF10,STC,8/1/2008,5.21,45.1,4.69,37,73.9,173.4,-
KUT0006,Termination,STC,8/19/2008,5.23,45,4.62,37.3,73.2,172.5,-
KUT0007,Baseline,STC,3/11/2008,5.25,44.4,4.87,35.8,74.6,174.2,52.1
KUT0007,UV,STC,6/5/2008,5.39,43.9,4.84,35.5,72.5,171.7,-
KUT0007,TC50,STC,7/4/2008,5.56,44.7,4.87,36.8,72.2,179.3,-
KUT0007,HF10,STC,8/1/2008,5.5,44.6,4.85,36.4,72.2,176.8,-
KUT0005,Baseline,STC,3/11/2008,5.13,44.3,4.84,35.6,75.7,172.3,51.7
KUT0005,Damp Heat,STC,5/8/2008,5.11,45.5,4.7,37.4,75.4,175.6,-
KUT0005,Static Load,STC,5/29/2008,4.95,45.6,4.67,37.6,77.6,175.5,-
KUT0008,Baseline,STC,3/11/2008,5.13,44.6,4.84,36,76.2,174.4,52.2
KUT0008,Damp Heat,STC,5/8/2008,5.17,44.9,4.78,36.2,74.4,172.7,-
KUT0008,Hail,STC,5/21/2008,5.14,44.5,4.73,35.8,74,169.4,-
KUT0011,Baseline,STC,3/11/2008,5.24,44.7,4.99,35.8,76.1,178.4,51.9
KUT0011,Outdoor Exposure,STC,4/17/2008,5.05,44.3,4.79,35.6,76.4,170.7,-
And here is the table schema:
Table Schema