DuckDB pandas pass DataFrame by name easily with IntelliSense support
02:26 20 Mar 2024

In DuckDB, we have to directly use the DataFrame variable name as a string in the SQL syntax (as shown here):

import pandas as pd
import duckdb

mydf = pd.DataFrame({'a' : [1, 2, 3]})
print(duckdb.query("SELECT SUM(a) FROM mydf").to_df())

But in VS Code the IntelliSense will not recognise the reference to mydf in the second statement, and it will mark mydf as unreferenced. And if mydf is renamed with IntelliSense, of course the second statement will break. Is there any way to make IntelliSense work?

python pandas dataframe visual-studio-code duckdb