crystal-lang / crystal-sqlite3

SQLite3 bindings for Crystal
MIT License
139 stars 30 forks source link

Create database instance for further usage #32

Open starkgate opened 6 years ago

starkgate commented 6 years ago

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.

bcardiff commented 6 years ago

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

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

starkgate commented 6 years ago

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

Indribell commented 5 years ago

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