Skip to content

Instantly share code, notes, and snippets.

@hokaccha hokaccha/sql.ipynb
Created Jan 17, 2016

Embed
What would you like to do?
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python2.7/site-packages/IPython/config.py:13: ShimWarning: The `IPython.config` package has been deprecated. You should import from traitlets.config instead.\n",
" \"You should import from traitlets.config instead.\", ShimWarning)\n",
"/usr/local/lib/python2.7/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.\n",
" warn(\"IPython.utils.traitlets has moved to a top-level traitlets package.\")\n"
]
}
],
"source": [
"%load_ext sql"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"↑このwarningは直すPull Requestあるけど取り込まれてない https://github.com/catherinedevlin/ipython-sql/pull/42"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"u'Connected: hokamura@adventar_dev'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%sql postgresql://hokamura@localhost/adventar_dev"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"22 rows affected.\n"
]
},
{
"data": {
"text/html": [
"<table>\n",
" <tr>\n",
" <th>id</th>\n",
" <th>title</th>\n",
" </tr>\n",
" <tr>\n",
" <td>1</td>\n",
" <td>CSS Preprocessor</td>\n",
" </tr>\n",
" <tr>\n",
" <td>2</td>\n",
" <td>CSS Programming</td>\n",
" </tr>\n",
" <tr>\n",
" <td>4</td>\n",
" <td>駄菓子屋</td>\n",
" </tr>\n",
" <tr>\n",
" <td>5</td>\n",
" <td>Maker Faire Tokyo 2012</td>\n",
" </tr>\n",
" <tr>\n",
" <td>9</td>\n",
" <td>広島東洋カープ</td>\n",
" </tr>\n",
" <tr>\n",
" <td>10</td>\n",
" <td>GraphicalWeb (CSS, SVG, WebGL etc)</td>\n",
" </tr>\n",
" <tr>\n",
" <td>11</td>\n",
" <td>imada</td>\n",
" </tr>\n",
" <tr>\n",
" <td>12</td>\n",
" <td>Workflow</td>\n",
" </tr>\n",
" <tr>\n",
" <td>13</td>\n",
" <td>Tech Pets</td>\n",
" </tr>\n",
" <tr>\n",
" <td>14</td>\n",
" <td>Fireworks Lover</td>\n",
" </tr>\n",
" <tr>\n",
" <td>15</td>\n",
" <td>Backbone.js</td>\n",
" </tr>\n",
" <tr>\n",
" <td>17</td>\n",
" <td>Vim</td>\n",
" </tr>\n",
" <tr>\n",
" <td>18</td>\n",
" <td>RubyMotion</td>\n",
" </tr>\n",
" <tr>\n",
" <td>19</td>\n",
" <td>#LOVEFONT</td>\n",
" </tr>\n",
" <tr>\n",
" <td>20</td>\n",
" <td>Sublime Text 2</td>\n",
" </tr>\n",
" <tr>\n",
" <td>22</td>\n",
" <td>Web Music Developers JP</td>\n",
" </tr>\n",
" <tr>\n",
" <td>23</td>\n",
" <td>Sencha</td>\n",
" </tr>\n",
" <tr>\n",
" <td>24</td>\n",
" <td>Symfony</td>\n",
" </tr>\n",
" <tr>\n",
" <td>26</td>\n",
" <td>Movable Type</td>\n",
" </tr>\n",
" <tr>\n",
" <td>27</td>\n",
" <td>HTML5</td>\n",
" </tr>\n",
" <tr>\n",
" <td>28</td>\n",
" <td>WebCMS</td>\n",
" </tr>\n",
" <tr>\n",
" <td>29</td>\n",
" <td>軽めのjQuery</td>\n",
" </tr>\n",
"</table>"
],
"text/plain": [
"[(1, u'CSS Preprocessor'),\n",
" (2, u'CSS Programming'),\n",
" (4, u'\\u99c4\\u83d3\\u5b50\\u5c4b'),\n",
" (5, u'Maker Faire Tokyo 2012'),\n",
" (9, u'\\u5e83\\u5cf6\\u6771\\u6d0b\\u30ab\\u30fc\\u30d7'),\n",
" (10, u'GraphicalWeb (CSS, SVG, WebGL etc)'),\n",
" (11, u'imada'),\n",
" (12, u'Workflow'),\n",
" (13, u'Tech Pets'),\n",
" (14, u'Fireworks Lover'),\n",
" (15, u'Backbone.js'),\n",
" (17, u'Vim'),\n",
" (18, u'RubyMotion'),\n",
" (19, u'#LOVEFONT'),\n",
" (20, u'Sublime Text 2'),\n",
" (22, u'Web Music Developers JP'),\n",
" (23, u'Sencha'),\n",
" (24, u'Symfony'),\n",
" (26, u'Movable Type'),\n",
" (27, u'HTML5'),\n",
" (28, u'WebCMS'),\n",
" (29, u'\\u8efd\\u3081\\u306ejQuery')]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%sql\n",
"select id, title\n",
"from calendars\n",
"where id < 30"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.