Home > database >  How should I fix this code with RuntimeError: Catalog Error: Schema with name a does not exist!? (SQ
How should I fix this code with RuntimeError: Catalog Error: Schema with name a does not exist!? (SQ

Time:03-30

I have 2 tables as shown below:

T_Emp

T_Grad

I want to find the Employee's Full name with Grad and Salary which order by City. Here is my code:

import duckdb
con = duckdb.connect(database=':memory:')

con.execute("""
select
    a.CONCAT(FirstName , ' ' ,LastName) as FullName,
    b.GradID,
    b.Salary
from
    T_Emp a
full join
  T_Grad b
on
  a.GradID = b.GradID
order by City;
""").df()

The error that I got :

ERROR:root:An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 0))

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-30-85b9d80141b2> in <module>()
     11   a.GradID = b.GradID
     12 order by City;
---> 13 """).df()

RuntimeError: Catalog Error: Schema with name a does not exist!
LINE 3:     a.CONCAT(FirstName , ' ' ,LastN...

CodePudding user response:

You have the wrong query to concat string, here is how you can fix it:

CONCAT(a.FirstName , ' ' ,a.LastName) as FullName
  • Related