ipython-sql icon indicating copy to clipboard operation
ipython-sql copied to clipboard

Use variables as table names

Open ghost opened this issue 6 years ago • 1 comments

Hi!

I would like to use a variable as table name. However, just doing something like

table_name = 'my_table'
%sql select count() from :table_name

does not work because :table_name is substituted to 'my_table', which is not a valid table in the database that I use (ClickHouse).

Is there a way to set table names from variables, yet use magic and not bare SQLAlchemy?

ghost avatar May 23 '19 19:05 ghost

%sql select count() from {table_name}

EminUZUN avatar Jul 17 '20 08:07 EminUZUN