# Try to create table, but database is closed

**URL:** https://discourse.julialang.org/t/try-to-create-table-but-database-is-closed/136271
**Category:** General Usage
**Tags:** sqlite
**Created:** [March 19, 2026, 8:48am UTC](https://discourse.julialang.org/t/try-to-create-table-but-database-is-closed/136271 "2026-03-19T08:48:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![phma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phma/32/6576_2.png) [@phma](https://discourse.julialang.org/u/phma)
#### Post date: [March 19, 2026, 8:48am UTC](https://discourse.julialang.org/t/try-to-create-table-but-database-is-closed/136271/1 "2026-03-19T08:48:55Z")

</div>

I’ve created a database and am trying to create a table in it.

```julia-auto
mkpath(spoolDir*"database")
db=SQLite.DB(spoolDir*"database/foo.db")

function makeTables()
  global db
  SQLite.execute(db,"create table if not exists nodes"*
    "(id integer primary key,x integer,y integer,z integer,ip text)")
end

```

The empty database file has been there since I created it a few weeks ago. But when I call `makeTables`, I get `ERROR: SQLiteException("DB is closed")`. How do I open it?
