Skip to content

Added alternative example #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added alternative example #37

wants to merge 1 commit into from

Conversation

Indribell
Copy link

As people can have no background in Ruby or Crystal, the following example will be more familiar to them coming from languages like PHP/...

See also Issue #32

@RX14
Copy link
Member

RX14 commented Jan 16, 2019

I think it'd be better to replace the other example, it's not a very good first impression.

@Indribell
Copy link
Author

I think it'd be better to replace the other example, it's not a very good first impression.

In that case it will require replacing the examples on the Sqlite, PostgreSQL and Mysql pages because all 3 drivers use the almost exact same example.

db = DB.open "sqlite3://./data.db"
db.exec "CREATE TABLE IF NOT EXISTS contacts (name text, age integer)"
db.exec "INSERT INTO contacts VALUES (?, ?)", "John Doe", 30
contacts = db.query_all "SELECT name, age FROM contacts", as: {name: String, age: Int64}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we close the db connection sometime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants