|
31 | 31 | }, |
32 | 32 | { |
33 | 33 | "cell_type": "code", |
34 | | - "execution_count": 1, |
| 34 | + "execution_count": 5, |
35 | 35 | "metadata": {}, |
36 | 36 | "outputs": [ |
37 | | - { |
38 | | - "name": "stderr", |
39 | | - "output_type": "stream", |
40 | | - "text": [ |
41 | | - "[2024-08-14 03:55:54,328][INFO]: Connecting root@localhost:3306\n", |
42 | | - "[2024-08-14 03:55:54,347][INFO]: Connected root@localhost:3306\n" |
43 | | - ] |
44 | | - }, |
45 | 37 | { |
46 | 38 | "data": { |
47 | 39 | "text/plain": [ |
48 | 40 | "DataJoint connection (connected) root@localhost:3306" |
49 | 41 | ] |
50 | 42 | }, |
51 | | - "execution_count": 1, |
| 43 | + "execution_count": 5, |
52 | 44 | "metadata": {}, |
53 | 45 | "output_type": "execute_result" |
54 | 46 | } |
|
66 | 58 | "If you are reading this text to also learn SQL, you can use two ways to issue queries: with IPython magic commands or a client library." |
67 | 59 | ] |
68 | 60 | }, |
| 61 | + { |
| 62 | + "cell_type": "markdown", |
| 63 | + "metadata": {}, |
| 64 | + "source": [ |
| 65 | + "If you are only learning DataJoint, you are done.\n", |
| 66 | + "If you are reading this text to also learn SQL, you can use two ways to issue queries: with IPython magic commands or a client library." |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "markdown", |
| 71 | + "metadata": {}, |
| 72 | + "source": [ |
| 73 | + "If you are only learning DataJoint, you are done.\n", |
| 74 | + "If you are reading this text to also learn SQL, you can use two ways to issue queries: with IPython magic commands or a client library." |
| 75 | + ] |
| 76 | + }, |
69 | 77 | { |
70 | 78 | "cell_type": "markdown", |
71 | 79 | "metadata": {}, |
|
79 | 87 | }, |
80 | 88 | { |
81 | 89 | "cell_type": "code", |
82 | | - "execution_count": 2, |
| 90 | + "execution_count": null, |
83 | 91 | "metadata": {}, |
84 | 92 | "outputs": [], |
85 | 93 | "source": [ |
|
94 | 102 | ")\n", |
95 | 103 | "\n", |
96 | 104 | "%load_ext sql\n", |
97 | | - "%sql $connection_string" |
| 105 | + "%sql $connection_string\n", |
| 106 | + "\n", |
| 107 | + "%config SqlMagic.style = '_DEPRECATED_DEFAULT' # addresses a bug in the SQL magic extension\n", |
| 108 | + "\n" |
98 | 109 | ] |
99 | 110 | }, |
100 | 111 | { |
|
107 | 118 | }, |
108 | 119 | { |
109 | 120 | "cell_type": "code", |
110 | | - "execution_count": 3, |
| 121 | + "execution_count": 4, |
111 | 122 | "metadata": { |
112 | 123 | "vscode": { |
113 | 124 | "languageId": "sql" |
|
123 | 134 | ] |
124 | 135 | }, |
125 | 136 | { |
126 | | - "data": { |
127 | | - "text/html": [ |
128 | | - "<table>\n", |
129 | | - " <thead>\n", |
130 | | - " <tr>\n", |
131 | | - " <th>User</th>\n", |
132 | | - " </tr>\n", |
133 | | - " </thead>\n", |
134 | | - " <tbody>\n", |
135 | | - " <tr>\n", |
136 | | - " <td>debian-sys-maint</td>\n", |
137 | | - " </tr>\n", |
138 | | - " <tr>\n", |
139 | | - " <td>mysql.infoschema</td>\n", |
140 | | - " </tr>\n", |
141 | | - " <tr>\n", |
142 | | - " <td>mysql.session</td>\n", |
143 | | - " </tr>\n", |
144 | | - " <tr>\n", |
145 | | - " <td>mysql.sys</td>\n", |
146 | | - " </tr>\n", |
147 | | - " <tr>\n", |
148 | | - " <td>root</td>\n", |
149 | | - " </tr>\n", |
150 | | - " </tbody>\n", |
151 | | - "</table>" |
152 | | - ], |
153 | | - "text/plain": [ |
154 | | - "[('debian-sys-maint',),\n", |
155 | | - " ('mysql.infoschema',),\n", |
156 | | - " ('mysql.session',),\n", |
157 | | - " ('mysql.sys',),\n", |
158 | | - " ('root',)]" |
159 | | - ] |
160 | | - }, |
161 | | - "execution_count": 3, |
162 | | - "metadata": {}, |
163 | | - "output_type": "execute_result" |
| 137 | + "ename": "KeyError", |
| 138 | + "evalue": "'DEFAULT'", |
| 139 | + "output_type": "error", |
| 140 | + "traceback": [ |
| 141 | + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", |
| 142 | + "\u001b[31mKeyError\u001b[39m Traceback (most recent call last)", |
| 143 | + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mget_ipython\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrun_cell_magic\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43msql\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43m-- show all users\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[33;43mSELECT User FROM mysql.user\u001b[39;49m\u001b[38;5;130;43;01m\\n\u001b[39;49;00m\u001b[33;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n", |
| 144 | + "\u001b[36mFile \u001b[39m\u001b[32m/opt/conda/lib/python3.11/site-packages/IPython/core/interactiveshell.py:2565\u001b[39m, in \u001b[36mInteractiveShell.run_cell_magic\u001b[39m\u001b[34m(self, magic_name, line, cell)\u001b[39m\n\u001b[32m 2563\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m.builtin_trap:\n\u001b[32m 2564\u001b[39m args = (magic_arg_s, cell)\n\u001b[32m-> \u001b[39m\u001b[32m2565\u001b[39m result = \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 2567\u001b[39m \u001b[38;5;66;03m# The code below prevents the output from being displayed\u001b[39;00m\n\u001b[32m 2568\u001b[39m \u001b[38;5;66;03m# when using magics with decorator @output_can_be_silenced\u001b[39;00m\n\u001b[32m 2569\u001b[39m \u001b[38;5;66;03m# when the last Python token in the expression is a ';'.\u001b[39;00m\n\u001b[32m 2570\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mgetattr\u001b[39m(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, \u001b[38;5;28;01mFalse\u001b[39;00m):\n", |
| 145 | + "\u001b[36mFile \u001b[39m\u001b[32m/opt/conda/lib/python3.11/site-packages/sql/magic.py:219\u001b[39m, in \u001b[36mSqlMagic.execute\u001b[39m\u001b[34m(self, line, cell, local_ns)\u001b[39m\n\u001b[32m 216\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m\n\u001b[32m 218\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m219\u001b[39m result = \u001b[43msql\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrun\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparsed\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43msql\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muser_ns\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 221\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m (\n\u001b[32m 222\u001b[39m result \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 223\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(result, \u001b[38;5;28mstr\u001b[39m)\n\u001b[32m (...)\u001b[39m\u001b[32m 226\u001b[39m \u001b[38;5;66;03m# Instead of returning values, set variables directly in the\u001b[39;00m\n\u001b[32m 227\u001b[39m \u001b[38;5;66;03m# user's namespace. Variable names given by column names\u001b[39;00m\n\u001b[32m 229\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.autopandas:\n", |
| 146 | + "\u001b[36mFile \u001b[39m\u001b[32m/opt/conda/lib/python3.11/site-packages/sql/run.py:374\u001b[39m, in \u001b[36mrun\u001b[39m\u001b[34m(conn, sql, config, user_namespace)\u001b[39m\n\u001b[32m 372\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m result \u001b[38;5;129;01mand\u001b[39;00m config.feedback:\n\u001b[32m 373\u001b[39m \u001b[38;5;28mprint\u001b[39m(interpret_rowcount(result.rowcount))\n\u001b[32m--> \u001b[39m\u001b[32m374\u001b[39m resultset = \u001b[43mResultSet\u001b[49m\u001b[43m(\u001b[49m\u001b[43mresult\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 375\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m config.autopandas:\n\u001b[32m 376\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m resultset.DataFrame()\n", |
| 147 | + "\u001b[36mFile \u001b[39m\u001b[32m/opt/conda/lib/python3.11/site-packages/sql/run.py:116\u001b[39m, in \u001b[36mResultSet.__init__\u001b[39m\u001b[34m(self, sqlaproxy, config)\u001b[39m\n\u001b[32m 114\u001b[39m \u001b[38;5;28mlist\u001b[39m.\u001b[34m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m, sqlaproxy.fetchall())\n\u001b[32m 115\u001b[39m \u001b[38;5;28mself\u001b[39m.field_names = unduplicate_field_names(\u001b[38;5;28mself\u001b[39m.keys)\n\u001b[32m--> \u001b[39m\u001b[32m116\u001b[39m \u001b[38;5;28mself\u001b[39m.pretty = PrettyTable(\u001b[38;5;28mself\u001b[39m.field_names, style=\u001b[43mprettytable\u001b[49m\u001b[43m.\u001b[49m\u001b[34;43m__dict__\u001b[39;49m\u001b[43m[\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstyle\u001b[49m\u001b[43m.\u001b[49m\u001b[43mupper\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m)\n\u001b[32m 117\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 118\u001b[39m \u001b[38;5;28mlist\u001b[39m.\u001b[34m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m, [])\n", |
| 148 | + "\u001b[31mKeyError\u001b[39m: 'DEFAULT'" |
| 149 | + ] |
164 | 150 | } |
165 | 151 | ], |
166 | 152 | "source": [ |
|
250 | 236 | "name": "python", |
251 | 237 | "nbconvert_exporter": "python", |
252 | 238 | "pygments_lexer": "ipython3", |
253 | | - "version": "3.10.14" |
| 239 | + "version": "3.11.13" |
254 | 240 | } |
255 | 241 | }, |
256 | 242 | "nbformat": 4, |
|
0 commit comments