Skip to content

Commit f317c22

Browse files
committed
re-added index
1 parent 1304b8c commit f317c22

5 files changed

Lines changed: 54 additions & 29 deletions

File tree

_includes/leftnav.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<div class="leftnav">
22
<ul class="nav nav-list">
33
{% for group in page.nav %}
4-
<li class="nav-header">{{ group.name }}</li>
4+
{% capture group_url %}/{{ page.name }}/{{ group.url }}{% endcapture %}
5+
<li class="nav-header{% if page.url == node_url %} active{% endif %}">
6+
{% if page.url %}
7+
<a href="{{group.url}}">{{group.name}}</a>
8+
{% else %}
9+
{{group.name}}
10+
{% endif %}
11+
</li>
512
{% for node in group.articles %}
613
{% capture node_url %}/{{ page.name }}/{{ node.url }}{% endcapture %}
714
{% if page.url == node_url %}

_layouts/article.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
nav:
55
-
66
name: Overview
7+
url: index.html
78
articles:
89
-
910
title: Overview of Go's database/sql Package

importing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ changes. It also forces you to use the Go idioms instead of ad-hoc idioms that a
1515
particular driver author may have provided.
1616

1717
In this documentation, we'll use the excellent [MySQL
18-
drivers](https://github.com/go-sql-driver/mysql) from @arnehormann and
19-
@julienschmidt for examples.
18+
drivers](https://github.com/go-sql-driver/mysql) from @julienschmidt and @arnehormann
19+
for examples.
2020

2121
Add the following to the top of your Go source file:
2222

index.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
11
---
22
layout: article
3-
title: Overview
3+
title: Go database/sql tutorial
44
---
55

6-
To access databases in Go, you use a `sql.DB`. You use this type to create
7-
statements and transactions, execute queries, and fetch results.
6+
The idiomatic way to use a SQL, or SQL-like, database in Go is through the
7+
[database/sql package](http://golang.org/pkg/database/sql/). It provides a
8+
lightweight interface to a row-oriented database. This website is a
9+
reference for the most common aspects of how to use it.
810

9-
The first thing you should know is that **a `sql.DB` isn't a database
10-
connection**. It also doesn't map to any particular database software's notion
11-
of a "database" or "schema." It's an abstraction of the interface and existence
12-
of a database, which might be as varied as a local file, accessed through a network
13-
connection, or in-memory and in-process.
11+
Why is this needed? The package's documentation tells you what everything does,
12+
but it doesn't tell you how to use the package. Many of us find ourselves
13+
wishing for a quick-reference and a "getting started" orientation that tells
14+
stories instead of listing facts. Contributions are welcome; please send pull
15+
requests [here](https://github.com/VividCortex/go-database-sql-tutorial).
1416

15-
The `sql.DB` performs some important tasks for you behind the scenes:
16-
17-
* It opens and closes connections to the actual underlying database, via the driver.
18-
* It manages a pool of connections as needed, which may be a variety of things as mentioned.
19-
20-
The `sql.DB` abstraction is designed to keep you from worrying about how to
21-
manage concurrent access to the underlying datastore. A connection is marked
22-
in-use when you use it to perform a task, and then returned to the available
23-
pool when it's not in use anymore. One consequence of this is that **if you fail
24-
to release connections back to the pool, you can cause `db.SQL` to open a lot of
25-
connections**, potentially running out of resources (too many connections, too
26-
many open file handles, lack of available network ports, etc). We'll discuss
27-
more about this later.
28-
29-
After creating a `sql.DB`, you can use it to query the database that it
30-
represents, as well as creating statements and transactions.
31-
32-
**Next: [Importing a Database Driver](importing.html)**
17+
**Start: [Overview of Go's database/sql Package](overview.html)**

overview.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
layout: article
3+
title: Overview
4+
---
5+
6+
To access databases in Go, you use a `sql.DB`. You use this type to create
7+
statements and transactions, execute queries, and fetch results.
8+
9+
The first thing you should know is that **a `sql.DB` isn't a database
10+
connection**. It also doesn't map to any particular database software's notion
11+
of a "database" or "schema." It's an abstraction of the interface and existence
12+
of a database, which might be as varied as a local file, accessed through a network
13+
connection, or in-memory and in-process.
14+
15+
The `sql.DB` performs some important tasks for you behind the scenes:
16+
17+
* It opens and closes connections to the actual underlying database, via the driver.
18+
* It manages a pool of connections as needed, which may be a variety of things as mentioned.
19+
20+
The `sql.DB` abstraction is designed to keep you from worrying about how to
21+
manage concurrent access to the underlying datastore. A connection is marked
22+
in-use when you use it to perform a task, and then returned to the available
23+
pool when it's not in use anymore. One consequence of this is that **if you fail
24+
to release connections back to the pool, you can cause `db.SQL` to open a lot of
25+
connections**, potentially running out of resources (too many connections, too
26+
many open file handles, lack of available network ports, etc). We'll discuss
27+
more about this later.
28+
29+
After creating a `sql.DB`, you can use it to query the database that it
30+
represents, as well as creating statements and transactions.
31+
32+
**Next: [Importing a Database Driver](importing.html)**

0 commit comments

Comments
 (0)