crystal-sqlite3 icon indicating copy to clipboard operation
crystal-sqlite3 copied to clipboard

Create database instance for further usage

Open starkgate opened this issue 7 years ago • 3 comments

Inspired from the Ruby sqlite gem, here is an improvement I would like to see in the Crystal shard syntax : Being able to create a new database object, allowing usage everywhere in the code, as opposed to only in the 'do' block. Also would allow for usage of several databases at once. db = SQLite3::Database.new 'database.db'

You would then be able to run db.exec, db.query on this object.

starkgate avatar Jan 26 '18 07:01 starkgate

DB.open without a block will give you a Database instance .

Even with block syntax you are allowed to have multiple Database instances.

bcardiff avatar Jan 26 '18 13:01 bcardiff

I see, I wasn't aware of that (new to Crystal). I'll try it out, thank you.

starkgate avatar Jan 26 '18 21:01 starkgate

With the new example, i assume this issue can be closed?

Indribell avatar Jan 14 '19 02:01 Indribell