CREATE TABLE in SQLite Script in RStudio

Consider script.sql below. I (1): create a table; (2) manually insert values into the table; and (3) query from the created table.

script.sql

-- !preview conn=DBI::dbConnect(RSQLite::SQLite())
CREATE TEMPORARY TABLE my_table (
    id INTEGER PRIMARY KEY,
    name TEXT
);

INSERT INTO my_table (id, name)
VALUES (1, 'John'),
       (2, 'Jane'),
       (3, 'Alice');

SELECT * FROM my_table;

When I run script.sql in RStudio, however, I don't get an error but the message: 'No data available in table'.

Is there a syntactical reason this doesn't work? Or is it the RStudio context?

How do you 'run script.sql' in RStudio?

It's a standalone script, as shown here.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.