1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
MySQL
— SQLAlchemy 0.6.3 Documentation</title>
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/docs.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '0.6.3',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html'
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/init.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="top" title="SQLAlchemy 0.6.3 Documentation" href="../../index.html" />
<link rel="up" title="sqlalchemy.dialects" href="index.html" />
<link rel="next" title="Oracle" href="oracle.html" />
<link rel="prev" title="Microsoft SQL Server" href="mssql.html" />
</head>
<body>
<h1>SQLAlchemy 0.6.3 Documentation</h1>
<div id="search">
Search:
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" size="18" /> <input type="submit" value="Search" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<div class="versionheader">
Version: <span class="versionnum">0.6.3</span> Last Updated: 07/15/2010 12:35:47
</div>
<div class="clearboth"></div>
<div class="topnav">
<div id="pagecontrol">
<a href="../index.html">API Reference</a>
|
<a href="../../genindex.html">Index</a>
<div class="sourcelink">(<a href="../../_sources/reference/dialects/mysql.txt">view source)</div>
</div>
<div class="navbanner">
<a class="totoc" href="../../index.html">Table of Contents</a>
» <a href="../index.html" title="API Reference">API Reference</a>
» <a href="index.html" title="sqlalchemy.dialects">sqlalchemy.dialects</a>
»
MySQL
<div class="prevnext">
Previous:
<a href="mssql.html" title="previous chapter">Microsoft SQL Server</a>
Next:
<a href="oracle.html" title="next chapter">Oracle</a>
</div>
<h2>
MySQL
</h2>
</div>
<ul>
<li><a class="reference internal" href="#">MySQL</a><ul>
<li><a class="reference internal" href="#supported-versions-and-features">Supported Versions and Features</a></li>
<li><a class="reference internal" href="#connecting">Connecting</a></li>
<li><a class="reference internal" href="#data-types">Data Types</a></li>
<li><a class="reference internal" href="#connection-timeouts">Connection Timeouts</a></li>
<li><a class="reference internal" href="#storage-engines">Storage Engines</a></li>
<li><a class="reference internal" href="#keys">Keys</a></li>
<li><a class="reference internal" href="#sql-mode">SQL Mode</a></li>
<li><a class="reference internal" href="#mysql-sql-extensions">MySQL SQL Extensions</a></li>
<li><a class="reference internal" href="#troubleshooting">Troubleshooting</a></li>
<li><a class="reference internal" href="#mysql-column-types">MySQL Column Types</a></li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.mysqldb">MySQL-Python Notes</a><ul>
<li><a class="reference internal" href="#id1">Connecting</a></li>
<li><a class="reference internal" href="#character-sets">Character Sets</a></li>
<li><a class="reference internal" href="#known-issues">Known Issues</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.oursql">OurSQL Notes</a><ul>
<li><a class="reference internal" href="#id2">Connecting</a></li>
<li><a class="reference internal" href="#id3">Character Sets</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.mysqlconnector">MySQL-Connector Notes</a><ul>
<li><a class="reference internal" href="#id4">Connecting</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.pyodbc">pyodbc Notes</a><ul>
<li><a class="reference internal" href="#id5">Connecting</a></li>
<li><a class="reference internal" href="#limitations">Limitations</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.zxjdbc">zxjdbc Notes</a><ul>
<li><a class="reference internal" href="#jdbc-driver">JDBC Driver</a></li>
<li><a class="reference internal" href="#id6">Connecting</a></li>
<li><a class="reference internal" href="#id7">Character Sets</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="clearboth"></div>
</div>
<div class="document">
<div class="body">
<div class="section" id="module-sqlalchemy.dialects.mysql.base">
<span id="mysql"></span><h1>MySQL<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.base" title="Permalink to this headline">¶</a></h1>
<p>Support for the MySQL database.</p>
<div class="section" id="supported-versions-and-features">
<h2>Supported Versions and Features<a class="headerlink" href="#supported-versions-and-features" title="Permalink to this headline">¶</a></h2>
<p>SQLAlchemy supports 6 major MySQL versions: 3.23, 4.0, 4.1, 5.0, 5.1 and 6.0,
with capabilities increasing with more modern servers.</p>
<p>Versions 4.1 and higher support the basic SQL functionality that SQLAlchemy
uses in the ORM and SQL expressions. These versions pass the applicable tests
in the suite 100%. No heroic measures are taken to work around major missing
SQL features- if your server version does not support sub-selects, for
example, they won’t work in SQLAlchemy either.</p>
<p>Most available DBAPI drivers are supported; see below.</p>
<table border="1" class="docutils">
<colgroup>
<col width="71%" />
<col width="29%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Feature</th>
<th class="head">Minimum Version</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>sqlalchemy.orm</td>
<td>4.1.1</td>
</tr>
<tr><td>Table Reflection</td>
<td>3.23.x</td>
</tr>
<tr><td>DDL Generation</td>
<td>4.1.1</td>
</tr>
<tr><td>utf8/Full Unicode Connections</td>
<td>4.1.1</td>
</tr>
<tr><td>Transactions</td>
<td>3.23.15</td>
</tr>
<tr><td>Two-Phase Transactions</td>
<td>5.0.3</td>
</tr>
<tr><td>Nested Transactions</td>
<td>5.0.3</td>
</tr>
</tbody>
</table>
<p>See the official MySQL documentation for detailed information about features
supported in any given server release.</p>
</div>
<div class="section" id="connecting">
<h2>Connecting<a class="headerlink" href="#connecting" title="Permalink to this headline">¶</a></h2>
<p>See the API documentation on individual drivers for details on connecting.</p>
</div>
<div class="section" id="data-types">
<h2>Data Types<a class="headerlink" href="#data-types" title="Permalink to this headline">¶</a></h2>
<p>All of MySQL’s standard types are supported. These can also be specified within
table metadata, for the purpose of issuing CREATE TABLE statements
which include MySQL-specific extensions. The types are available
from the module, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.dialects</span> <span class="kn">import</span> <span class="n">mysql</span>
<span class="n">Table</span><span class="p">(</span><span class="s">'mytable'</span><span class="p">,</span> <span class="n">metadata</span><span class="p">,</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'id'</span><span class="p">,</span> <span class="n">Integer</span><span class="p">,</span> <span class="n">primary_key</span><span class="o">=</span><span class="bp">True</span><span class="p">),</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'ittybittyblob'</span><span class="p">,</span> <span class="n">mysql</span><span class="o">.</span><span class="n">TINYBLOB</span><span class="p">),</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'biggy'</span><span class="p">,</span> <span class="n">mysql</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">(</span><span class="n">unsigned</span><span class="o">=</span><span class="bp">True</span><span class="p">)))</span></pre></div>
</div>
<p>See the API documentation on specific column types for further details.</p>
</div>
<div class="section" id="connection-timeouts">
<h2>Connection Timeouts<a class="headerlink" href="#connection-timeouts" title="Permalink to this headline">¶</a></h2>
<p>MySQL features an automatic connection close behavior, for connections that have
been idle for eight hours or more. To circumvent having this issue, use the
<tt class="docutils literal"><span class="pre">pool_recycle</span></tt> option which controls the maximum age of any connection:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">engine</span> <span class="o">=</span> <span class="n">create_engine</span><span class="p">(</span><span class="s">'mysql+mysqldb://...'</span><span class="p">,</span> <span class="n">pool_recycle</span><span class="o">=</span><span class="mi">3600</span><span class="p">)</span></pre></div>
</div>
</div>
<div class="section" id="storage-engines">
<h2>Storage Engines<a class="headerlink" href="#storage-engines" title="Permalink to this headline">¶</a></h2>
<p>Most MySQL server installations have a default table type of <tt class="docutils literal"><span class="pre">MyISAM</span></tt>, a
non-transactional table type. During a transaction, non-transactional storage
engines do not participate and continue to store table changes in autocommit
mode. For fully atomic transactions, all participating tables must use a
transactional engine such as <tt class="docutils literal"><span class="pre">InnoDB</span></tt>, <tt class="docutils literal"><span class="pre">Falcon</span></tt>, <tt class="docutils literal"><span class="pre">SolidDB</span></tt>, <cite>PBXT</cite>, etc.</p>
<p>Storage engines can be elected when creating tables in SQLAlchemy by supplying
a <tt class="docutils literal"><span class="pre">mysql_engine='whatever'</span></tt> to the <tt class="docutils literal"><span class="pre">Table</span></tt> constructor. Any MySQL table
creation option can be specified in this syntax:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Table</span><span class="p">(</span><span class="s">'mytable'</span><span class="p">,</span> <span class="n">metadata</span><span class="p">,</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'data'</span><span class="p">,</span> <span class="n">String</span><span class="p">(</span><span class="mi">32</span><span class="p">)),</span>
<span class="n">mysql_engine</span><span class="o">=</span><span class="s">'InnoDB'</span><span class="p">,</span>
<span class="n">mysql_charset</span><span class="o">=</span><span class="s">'utf8'</span>
<span class="p">)</span></pre></div>
</div>
</div>
<div class="section" id="keys">
<h2>Keys<a class="headerlink" href="#keys" title="Permalink to this headline">¶</a></h2>
<p>Not all MySQL storage engines support foreign keys. For <tt class="docutils literal"><span class="pre">MyISAM</span></tt> and
similar engines, the information loaded by table reflection will not include
foreign keys. For these tables, you may supply a
<tt class="xref py py-class docutils literal"><span class="pre">ForeignKeyConstraint</span></tt> at reflection time:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Table</span><span class="p">(</span><span class="s">'mytable'</span><span class="p">,</span> <span class="n">metadata</span><span class="p">,</span>
<span class="n">ForeignKeyConstraint</span><span class="p">([</span><span class="s">'other_id'</span><span class="p">],</span> <span class="p">[</span><span class="s">'othertable.other_id'</span><span class="p">]),</span>
<span class="n">autoload</span><span class="o">=</span><span class="bp">True</span>
<span class="p">)</span></pre></div>
</div>
<p>When creating tables, SQLAlchemy will automatically set <tt class="docutils literal"><span class="pre">AUTO_INCREMENT`</span></tt> on
an integer primary key column:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">t</span> <span class="o">=</span> <span class="n">Table</span><span class="p">(</span><span class="s">'mytable'</span><span class="p">,</span> <span class="n">metadata</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">Column</span><span class="p">(</span><span class="s">'mytable_id'</span><span class="p">,</span> <span class="n">Integer</span><span class="p">,</span> <span class="n">primary_key</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="gp">... </span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">t</span><span class="o">.</span><span class="n">create</span><span class="p">()</span>
<span class="go">CREATE TABLE mytable (</span>
<span class="go"> id INTEGER NOT NULL AUTO_INCREMENT,</span>
<span class="go"> PRIMARY KEY (id)</span>
<span class="go">)</span></pre></div>
</div>
<p>You can disable this behavior by supplying <tt class="docutils literal"><span class="pre">autoincrement=False</span></tt> to the
<tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt>. This flag can also be used to enable
auto-increment on a secondary column in a multi-column key for some storage
engines:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Table</span><span class="p">(</span><span class="s">'mytable'</span><span class="p">,</span> <span class="n">metadata</span><span class="p">,</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'gid'</span><span class="p">,</span> <span class="n">Integer</span><span class="p">,</span> <span class="n">primary_key</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">autoincrement</span><span class="o">=</span><span class="bp">False</span><span class="p">),</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'id'</span><span class="p">,</span> <span class="n">Integer</span><span class="p">,</span> <span class="n">primary_key</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="p">)</span></pre></div>
</div>
</div>
<div class="section" id="sql-mode">
<h2>SQL Mode<a class="headerlink" href="#sql-mode" title="Permalink to this headline">¶</a></h2>
<p>MySQL SQL modes are supported. Modes that enable <tt class="docutils literal"><span class="pre">ANSI_QUOTES</span></tt> (such as
<tt class="docutils literal"><span class="pre">ANSI</span></tt>) require an engine option to modify SQLAlchemy’s quoting style.
When using an ANSI-quoting mode, supply <tt class="docutils literal"><span class="pre">use_ansiquotes=True</span></tt> when
creating your <tt class="docutils literal"><span class="pre">Engine</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">create_engine</span><span class="p">(</span><span class="s">'mysql://localhost/test'</span><span class="p">,</span> <span class="n">use_ansiquotes</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span></pre></div>
</div>
<p>This is an engine-wide option and is not toggleable on a per-connection basis.
SQLAlchemy does not presume to <tt class="docutils literal"><span class="pre">SET</span> <span class="pre">sql_mode</span></tt> for you with this option. For
the best performance, set the quoting style server-wide in <tt class="docutils literal"><span class="pre">my.cnf</span></tt> or by
supplying <tt class="docutils literal"><span class="pre">--sql-mode</span></tt> to <tt class="docutils literal"><span class="pre">mysqld</span></tt>. You can also use a
<a class="reference internal" href="../sqlalchemy/pooling.html#sqlalchemy.pool.Pool" title="sqlalchemy.pool.Pool"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.pool.Pool</span></tt></a> listener hook to issue a <tt class="docutils literal"><span class="pre">SET</span> <span class="pre">SESSION</span>
<span class="pre">sql_mode='...'</span></tt> on connect to configure each connection.</p>
<p>If you do not specify <tt class="docutils literal"><span class="pre">use_ansiquotes</span></tt>, the regular MySQL quoting style is
used by default.</p>
<p>If you do issue a <tt class="docutils literal"><span class="pre">SET</span> <span class="pre">sql_mode</span></tt> through SQLAlchemy, the dialect must be
updated if the quoting style is changed. Again, this change will affect all
connections:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s">'SET sql_mode="ansi"'</span><span class="p">)</span>
<span class="n">connection</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">use_ansiquotes</span> <span class="o">=</span> <span class="bp">True</span></pre></div>
</div>
</div>
<div class="section" id="mysql-sql-extensions">
<h2>MySQL SQL Extensions<a class="headerlink" href="#mysql-sql-extensions" title="Permalink to this headline">¶</a></h2>
<p>Many of the MySQL SQL extensions are handled through SQLAlchemy’s generic
function and operator support:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">table</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">password</span><span class="o">==</span><span class="n">func</span><span class="o">.</span><span class="n">md5</span><span class="p">(</span><span class="s">'plaintext'</span><span class="p">))</span>
<span class="n">table</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">username</span><span class="o">.</span><span class="n">op</span><span class="p">(</span><span class="s">'regexp'</span><span class="p">)(</span><span class="s">'^[a-d]'</span><span class="p">))</span></pre></div>
</div>
<p>And of course any valid MySQL statement can be executed as a string as well.</p>
<p>Some limited direct support for MySQL extensions to SQL is currently
available.</p>
<ul>
<li><p class="first">SELECT pragma:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">select</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">prefixes</span><span class="o">=</span><span class="p">[</span><span class="s">'HIGH_PRIORITY'</span><span class="p">,</span> <span class="s">'SQL_SMALL_RESULT'</span><span class="p">])</span></pre></div>
</div>
</li>
<li><p class="first">UPDATE with LIMIT:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">update</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">mysql_limit</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span></pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="troubleshooting">
<h2>Troubleshooting<a class="headerlink" href="#troubleshooting" title="Permalink to this headline">¶</a></h2>
<p>If you have problems that seem server related, first check that you are
using the most recent stable MySQL-Python package available. The Database
Notes page on the wiki at <a class="reference external" href="http://www.sqlalchemy.org">http://www.sqlalchemy.org</a> is a good resource for
timely information affecting MySQL in SQLAlchemy.</p>
</div>
<div class="section" id="mysql-column-types">
<h2>MySQL Column Types<a class="headerlink" href="#mysql-column-types" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.NUMERIC">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">NUMERIC</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=True</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.NUMERIC" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._NumericType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.NUMERIC" title="sqlalchemy.types.NUMERIC"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.NUMERIC</span></tt></a></p>
<p>MySQL NUMERIC type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.NUMERIC.__init__">
<tt class="descname">__init__</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=True</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.NUMERIC.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a NUMERIC.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>precision</strong> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><strong>scale</strong> – The number of digits after the decimal point.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.DECIMAL">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">DECIMAL</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=True</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.DECIMAL" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._NumericType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.DECIMAL" title="sqlalchemy.types.DECIMAL"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.DECIMAL</span></tt></a></p>
<p>MySQL DECIMAL type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.DECIMAL.__init__">
<tt class="descname">__init__</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=True</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.DECIMAL.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a DECIMAL.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>precision</strong> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><strong>scale</strong> – The number of digits after the decimal point.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.DOUBLE">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">DOUBLE</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=True</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.DOUBLE" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._FloatType</span></tt></p>
<p>MySQL DOUBLE type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.DOUBLE.__init__">
<tt class="descname">__init__</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=True</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.DOUBLE.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a DOUBLE.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>precision</strong> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><strong>scale</strong> – The number of digits after the decimal point.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.REAL">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">REAL</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=True</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.REAL" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._FloatType</span></tt></p>
<p>MySQL REAL type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.REAL.__init__">
<tt class="descname">__init__</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=True</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.REAL.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a REAL.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>precision</strong> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><strong>scale</strong> – The number of digits after the decimal point.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.FLOAT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">FLOAT</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=False</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.FLOAT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._FloatType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.FLOAT" title="sqlalchemy.types.FLOAT"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.FLOAT</span></tt></a></p>
<p>MySQL FLOAT type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.FLOAT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>precision=None</em>, <em>scale=None</em>, <em>asdecimal=False</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.FLOAT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a FLOAT.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>precision</strong> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><strong>scale</strong> – The number of digits after the decimal point.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.INTEGER">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">INTEGER</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.INTEGER" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._IntegerType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.INTEGER" title="sqlalchemy.types.INTEGER"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.INTEGER</span></tt></a></p>
<p>MySQL INTEGER type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.INTEGER.__init__">
<tt class="descname">__init__</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.INTEGER.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct an INTEGER.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>display_width</strong> – Optional, maximum display width for this number.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.BIGINT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">BIGINT</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BIGINT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._IntegerType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.BIGINT" title="sqlalchemy.types.BIGINT"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.BIGINT</span></tt></a></p>
<p>MySQL BIGINTEGER type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.BIGINT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BIGINT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a BIGINTEGER.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>display_width</strong> – Optional, maximum display width for this number.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.MEDIUMINT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">MEDIUMINT</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.MEDIUMINT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._IntegerType</span></tt></p>
<p>MySQL MEDIUMINTEGER type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.MEDIUMINT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.MEDIUMINT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a MEDIUMINTEGER</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>display_width</strong> – Optional, maximum display width for this number.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.TINYINT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">TINYINT</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TINYINT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._IntegerType</span></tt></p>
<p>MySQL TINYINT type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.TINYINT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TINYINT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a TINYINT.</p>
<p>Note: following the usual MySQL conventions, TINYINT(1) columns
reflected during Table(..., autoload=True) are treated as
Boolean columns.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>display_width</strong> – Optional, maximum display width for this number.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.SMALLINT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">SMALLINT</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.SMALLINT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._IntegerType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.SMALLINT" title="sqlalchemy.types.SMALLINT"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.SMALLINT</span></tt></a></p>
<p>MySQL SMALLINTEGER type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.SMALLINT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>display_width=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.SMALLINT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a SMALLINTEGER.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>display_width</strong> – Optional, maximum display width for this number.</li>
<li><strong>unsigned</strong> – a boolean, optional.</li>
<li><strong>zerofill</strong> – Optional. If true, values will be stored as strings
left-padded with zeros. Note that this does not effect the values
returned by the underlying database API, which continue to be
numeric.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.BIT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">BIT</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BIT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.TypeEngine</span></tt></a></p>
<p>MySQL BIT type.</p>
<p>This type is for MySQL 5.0.3 or greater for MyISAM, and 5.0.5 or greater for
MyISAM, MEMORY, InnoDB and BDB. For older versions, use a MSTinyInteger()
type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.BIT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BIT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a BIT.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>length</strong> – Optional, number of bits.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.DATETIME">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">DATETIME</tt><big>(</big><em>timezone=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.DATETIME" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.DateTime" title="sqlalchemy.types.DateTime"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.DateTime</span></tt></a></p>
<p>The SQL DATETIME type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.DATETIME.__init__">
<tt class="descname">__init__</tt><big>(</big><em>timezone=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.DATETIME.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.DATE">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">DATE</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.DATE" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.Date" title="sqlalchemy.types.Date"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.Date</span></tt></a></p>
<p>The SQL DATE type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.DATE.__init__">
<tt class="descname">__init__</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.DATE.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.TIME">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">TIME</tt><big>(</big><em>timezone=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TIME" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.Time" title="sqlalchemy.types.Time"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.Time</span></tt></a></p>
<p>The SQL TIME type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.TIME.__init__">
<tt class="descname">__init__</tt><big>(</big><em>timezone=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TIME.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.TIMESTAMP">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">TIMESTAMP</tt><big>(</big><em>timezone=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TIMESTAMP" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.TIMESTAMP" title="sqlalchemy.types.TIMESTAMP"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.TIMESTAMP</span></tt></a></p>
<p>MySQL TIMESTAMP type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.TIMESTAMP.__init__">
<tt class="descname">__init__</tt><big>(</big><em>timezone=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TIMESTAMP.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.YEAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">YEAR</tt><big>(</big><em>display_width=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.YEAR" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.TypeEngine</span></tt></a></p>
<p>MySQL YEAR type, for single byte storage of years 1901-2155.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.YEAR.__init__">
<tt class="descname">__init__</tt><big>(</big><em>display_width=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.YEAR.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.TEXT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">TEXT</tt><big>(</big><em>length=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TEXT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.TEXT" title="sqlalchemy.types.TEXT"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.TEXT</span></tt></a></p>
<p>MySQL TEXT type, for text up to 2^16 characters.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.TEXT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TEXT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a TEXT.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>length</strong> – Optional, if provided the server may optimize storage
by substituting the smallest TEXT type sufficient to store
<tt class="docutils literal"><span class="pre">length</span></tt> characters.</li>
<li><strong>charset</strong> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><strong>collation</strong> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><strong>ascii</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">latin1</span></tt>
character set, generates ASCII in schema.</li>
<li><strong>unicode</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">ucs2</span></tt>
character set, generates UNICODE in schema.</li>
<li><strong>national</strong> – Optional. If true, use the server’s configured
national character set.</li>
<li><strong>binary</strong> – Defaults to False: short-hand, pick the binary
collation type that matches the column’s character set. Generates
BINARY in schema. This does not affect the type of data stored,
only the collation of character data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.TINYTEXT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">TINYTEXT</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TINYTEXT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt></p>
<p>MySQL TINYTEXT type, for text up to 2^8 characters.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.TINYTEXT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TINYTEXT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a TINYTEXT.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>charset</strong> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><strong>collation</strong> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><strong>ascii</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">latin1</span></tt>
character set, generates ASCII in schema.</li>
<li><strong>unicode</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">ucs2</span></tt>
character set, generates UNICODE in schema.</li>
<li><strong>national</strong> – Optional. If true, use the server’s configured
national character set.</li>
<li><strong>binary</strong> – Defaults to False: short-hand, pick the binary
collation type that matches the column’s character set. Generates
BINARY in schema. This does not affect the type of data stored,
only the collation of character data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.MEDIUMTEXT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">MEDIUMTEXT</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.MEDIUMTEXT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt></p>
<p>MySQL MEDIUMTEXT type, for text up to 2^24 characters.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.MEDIUMTEXT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.MEDIUMTEXT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a MEDIUMTEXT.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>charset</strong> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><strong>collation</strong> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><strong>ascii</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">latin1</span></tt>
character set, generates ASCII in schema.</li>
<li><strong>unicode</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">ucs2</span></tt>
character set, generates UNICODE in schema.</li>
<li><strong>national</strong> – Optional. If true, use the server’s configured
national character set.</li>
<li><strong>binary</strong> – Defaults to False: short-hand, pick the binary
collation type that matches the column’s character set. Generates
BINARY in schema. This does not affect the type of data stored,
only the collation of character data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.LONGTEXT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">LONGTEXT</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.LONGTEXT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt></p>
<p>MySQL LONGTEXT type, for text up to 2^32 characters.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.LONGTEXT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.LONGTEXT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a LONGTEXT.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>charset</strong> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><strong>collation</strong> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><strong>ascii</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">latin1</span></tt>
character set, generates ASCII in schema.</li>
<li><strong>unicode</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">ucs2</span></tt>
character set, generates UNICODE in schema.</li>
<li><strong>national</strong> – Optional. If true, use the server’s configured
national character set.</li>
<li><strong>binary</strong> – Defaults to False: short-hand, pick the binary
collation type that matches the column’s character set. Generates
BINARY in schema. This does not affect the type of data stored,
only the collation of character data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.VARCHAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">VARCHAR</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.VARCHAR" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.VARCHAR" title="sqlalchemy.types.VARCHAR"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.VARCHAR</span></tt></a></p>
<p>MySQL VARCHAR type, for variable-length character data.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.VARCHAR.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.VARCHAR.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a VARCHAR.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>charset</strong> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><strong>collation</strong> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><strong>ascii</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">latin1</span></tt>
character set, generates ASCII in schema.</li>
<li><strong>unicode</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">ucs2</span></tt>
character set, generates UNICODE in schema.</li>
<li><strong>national</strong> – Optional. If true, use the server’s configured
national character set.</li>
<li><strong>binary</strong> – Defaults to False: short-hand, pick the binary
collation type that matches the column’s character set. Generates
BINARY in schema. This does not affect the type of data stored,
only the collation of character data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.CHAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">CHAR</tt><big>(</big><em>length</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.CHAR" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.CHAR" title="sqlalchemy.types.CHAR"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.CHAR</span></tt></a></p>
<p>MySQL CHAR type, for fixed-length character data.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.CHAR.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.CHAR.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a CHAR.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>length</strong> – Maximum data length, in characters.</li>
<li><strong>binary</strong> – Optional, use the default binary collation for the
national character set. This does not affect the type of data
stored, use a BINARY type for binary data.</li>
<li><strong>collation</strong> – Optional, request a particular collation. Must be
compatible with the national character set.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.NVARCHAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">NVARCHAR</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.NVARCHAR" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.NVARCHAR" title="sqlalchemy.types.NVARCHAR"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.NVARCHAR</span></tt></a></p>
<p>MySQL NVARCHAR type.</p>
<p>For variable-length character data in the server’s configured national
character set.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.NVARCHAR.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.NVARCHAR.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct an NVARCHAR.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>length</strong> – Maximum data length, in characters.</li>
<li><strong>binary</strong> – Optional, use the default binary collation for the
national character set. This does not affect the type of data
stored, use a BINARY type for binary data.</li>
<li><strong>collation</strong> – Optional, request a particular collation. Must be
compatible with the national character set.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.NCHAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">NCHAR</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.NCHAR" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt>, <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.NCHAR" title="sqlalchemy.types.NCHAR"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.NCHAR</span></tt></a></p>
<p>MySQL NCHAR type.</p>
<p>For fixed-length character data in the server’s configured national
character set.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.NCHAR.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.NCHAR.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct an NCHAR. Arguments are:</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>length</strong> – Maximum data length, in characters.</li>
<li><strong>binary</strong> – Optional, use the default binary collation for the
national character set. This does not affect the type of data
stored, use a BINARY type for binary data.</li>
<li><strong>collation</strong> – Optional, request a particular collation. Must be
compatible with the national character set.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.VARBINARY">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">VARBINARY</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.VARBINARY" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types._Binary</span></tt></p>
<p>The SQL VARBINARY type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.VARBINARY.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.VARBINARY.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.BINARY">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">BINARY</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BINARY" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types._Binary</span></tt></p>
<p>The SQL BINARY type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.BINARY.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BINARY.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.BLOB">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">BLOB</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BLOB" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.LargeBinary" title="sqlalchemy.types.LargeBinary"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.LargeBinary</span></tt></a></p>
<p>The SQL BLOB type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.BLOB.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BLOB.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a LargeBinary type.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>length</strong> – optional, a length for the column for use in
DDL statements, for those BLOB types that accept a length
(i.e. MySQL). It does <em>not</em> produce a small BINARY/VARBINARY
type - use the BINARY/VARBINARY types specifically for those.
May be safely omitted if no <tt class="docutils literal"><span class="pre">CREATE</span>
<span class="pre">TABLE</span></tt> will be issued. Certain databases may require a
<em>length</em> for use in DDL, and will raise an exception when
the <tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">TABLE</span></tt> DDL is issued.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.TINYBLOB">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">TINYBLOB</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TINYBLOB" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types._Binary</span></tt></p>
<p>MySQL TINYBLOB type, for binary data up to 2^8 bytes.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.TINYBLOB.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.TINYBLOB.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.MEDIUMBLOB">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">MEDIUMBLOB</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.MEDIUMBLOB" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types._Binary</span></tt></p>
<p>MySQL MEDIUMBLOB type, for binary data up to 2^24 bytes.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.MEDIUMBLOB.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.MEDIUMBLOB.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.LONGBLOB">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">LONGBLOB</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.LONGBLOB" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types._Binary</span></tt></p>
<p>MySQL LONGBLOB type, for binary data up to 2^32 bytes.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.LONGBLOB.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.LONGBLOB.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.ENUM">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">ENUM</tt><big>(</big><em>*enums</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.ENUM" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.Enum" title="sqlalchemy.types.Enum"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.Enum</span></tt></a>, <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt></p>
<p>MySQL ENUM type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.ENUM.__init__">
<tt class="descname">__init__</tt><big>(</big><em>*enums</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.ENUM.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct an ENUM.</p>
<p>Example:</p>
<blockquote>
Column(‘myenum’, MSEnum(“foo”, “bar”, “baz”))</blockquote>
<p>Arguments are:</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>enums</strong> – The range of valid values for this ENUM. Values will be
quoted when generating the schema according to the quoting flag (see
below).</li>
<li><strong>strict</strong> – Defaults to False: ensure that a given value is in this
ENUM’s range of permissible values when inserting or updating rows.
Note that MySQL will not raise a fatal error if you attempt to store
an out of range value- an alternate value will be stored instead.
(See MySQL ENUM documentation.)</li>
<li><strong>charset</strong> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><strong>collation</strong> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><strong>ascii</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">latin1</span></tt>
character set, generates ASCII in schema.</li>
<li><strong>unicode</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">ucs2</span></tt>
character set, generates UNICODE in schema.</li>
<li><strong>binary</strong> – Defaults to False: short-hand, pick the binary
collation type that matches the column’s character set. Generates
BINARY in schema. This does not affect the type of data stored,
only the collation of character data.</li>
<li><strong>quoting</strong> – <p>Defaults to ‘auto’: automatically determine enum value
quoting. If all enum values are surrounded by the same quoting
character, then use ‘quoted’ mode. Otherwise, use ‘unquoted’ mode.</p>
<p>‘quoted’: values in enums are already quoted, they will be used
directly when generating the schema - this usage is deprecated.</p>
<p>‘unquoted’: values in enums are not quoted, they will be escaped and
surrounded by single quotes when generating the schema.</p>
<p>Previous versions of this type always required manually quoted
values to be supplied; future versions will always quote the string
literals for you. This is a transitional option.</p>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.SET">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">SET</tt><big>(</big><em>*values</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.SET" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.dialects.mysql.base._StringType</span></tt></p>
<p>MySQL SET type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.SET.__init__">
<tt class="descname">__init__</tt><big>(</big><em>*values</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.SET.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a SET.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Column</span><span class="p">(</span><span class="s">'myset'</span><span class="p">,</span> <span class="n">MSSet</span><span class="p">(</span><span class="s">"'foo'"</span><span class="p">,</span> <span class="s">"'bar'"</span><span class="p">,</span> <span class="s">"'baz'"</span><span class="p">))</span></pre></div>
</div>
<p>Arguments are:</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>values</strong> – The range of valid values for this SET. Values will be
used exactly as they appear when generating schemas. Strings must
be quoted, as in the example above. Single-quotes are suggested for
ANSI compatibility and are required for portability to servers with
ANSI_QUOTES enabled.</li>
<li><strong>charset</strong> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><strong>collation</strong> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><strong>ascii</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">latin1</span></tt>
character set, generates ASCII in schema.</li>
<li><strong>unicode</strong> – Defaults to False: short-hand for the <tt class="docutils literal"><span class="pre">ucs2</span></tt>
character set, generates UNICODE in schema.</li>
<li><strong>binary</strong> – Defaults to False: short-hand, pick the binary
collation type that matches the column’s character set. Generates
BINARY in schema. This does not affect the type of data stored,
only the collation of character data.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.base.BOOLEAN">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.base.</tt><tt class="descname">BOOLEAN</tt><big>(</big><em>create_constraint=True</em>, <em>name=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BOOLEAN" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../sqlalchemy/types.html#sqlalchemy.types.Boolean" title="sqlalchemy.types.Boolean"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.Boolean</span></tt></a></p>
<p>The SQL BOOLEAN type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.base.BOOLEAN.__init__">
<tt class="descname">__init__</tt><big>(</big><em>create_constraint=True</em>, <em>name=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.base.BOOLEAN.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a Boolean.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>create_constraint</strong> – defaults to True. If the boolean
is generated as an int/smallint, also create a CHECK constraint
on the table that ensures 1 or 0 as a value.</li>
<li><strong>name</strong> – if a CHECK constraint is generated, specify
the name of the constraint.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.mysqldb">
<span id="mysql-python-notes"></span><h2>MySQL-Python Notes<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.mysqldb" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via the MySQL-python adapter.</p>
<p>MySQL-Python is available at:</p>
<blockquote>
<a class="reference external" href="http://sourceforge.net/projects/mysql-python">http://sourceforge.net/projects/mysql-python</a></blockquote>
<p>At least version 1.2.1 or 1.2.2 should be used.</p>
<div class="section" id="id1">
<h3>Connecting<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<p>Connect string format:</p>
<div class="highlight-python"><pre>mysql+mysqldb://<user>:<password>@<host>[:<port>]/<dbname></pre>
</div>
</div>
<div class="section" id="character-sets">
<h3>Character Sets<a class="headerlink" href="#character-sets" title="Permalink to this headline">¶</a></h3>
<p>Many MySQL server installations default to a <tt class="docutils literal"><span class="pre">latin1</span></tt> encoding for client
connections. All data sent through the connection will be converted into
<tt class="docutils literal"><span class="pre">latin1</span></tt>, even if you have <tt class="docutils literal"><span class="pre">utf8</span></tt> or another character set on your tables
and columns. With versions 4.1 and higher, you can change the connection
character set either through server configuration or by including the
<tt class="docutils literal"><span class="pre">charset</span></tt> parameter in the URL used for <tt class="docutils literal"><span class="pre">create_engine</span></tt>. The <tt class="docutils literal"><span class="pre">charset</span></tt>
option is passed through to MySQL-Python and has the side-effect of also
enabling <tt class="docutils literal"><span class="pre">use_unicode</span></tt> in the driver by default. For regular encoded
strings, also pass <tt class="docutils literal"><span class="pre">use_unicode=0</span></tt> in the connection arguments:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># set client encoding to utf8; all strings come back as unicode</span>
<span class="n">create_engine</span><span class="p">(</span><span class="s">'mysql+mysqldb:///mydb?charset=utf8'</span><span class="p">)</span>
<span class="c"># set client encoding to utf8; all strings come back as utf8 str</span>
<span class="n">create_engine</span><span class="p">(</span><span class="s">'mysql+mysqldb:///mydb?charset=utf8&use_unicode=0'</span><span class="p">)</span></pre></div>
</div>
</div>
<div class="section" id="known-issues">
<h3>Known Issues<a class="headerlink" href="#known-issues" title="Permalink to this headline">¶</a></h3>
<p>MySQL-python at least as of version 1.2.2 has a serious memory leak related
to unicode conversion, a feature which is disabled via <tt class="docutils literal"><span class="pre">use_unicode=0</span></tt>.
The recommended connection form with SQLAlchemy is:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">engine</span> <span class="o">=</span> <span class="n">create_engine</span><span class="p">(</span><span class="s">'mysql://scott:tiger@localhost/test?charset=utf8&use_unicode=0'</span><span class="p">,</span> <span class="n">pool_recycle</span><span class="o">=</span><span class="mi">3600</span><span class="p">)</span></pre></div>
</div>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.oursql">
<span id="oursql-notes"></span><h2>OurSQL Notes<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.oursql" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via the oursql adapter.</p>
<p>OurSQL is available at:</p>
<blockquote>
<a class="reference external" href="http://packages.python.org/oursql/">http://packages.python.org/oursql/</a></blockquote>
<div class="section" id="id2">
<h3>Connecting<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p>Connect string format:</p>
<div class="highlight-python"><pre>mysql+oursql://<user>:<password>@<host>[:<port>]/<dbname></pre>
</div>
</div>
<div class="section" id="id3">
<h3>Character Sets<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
<p>oursql defaults to using <tt class="docutils literal"><span class="pre">utf8</span></tt> as the connection charset, but other
encodings may be used instead. Like the MySQL-Python driver, unicode support
can be completely disabled:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># oursql sets the connection charset to utf8 automatically; all strings come</span>
<span class="c"># back as utf8 str</span>
<span class="n">create_engine</span><span class="p">(</span><span class="s">'mysql+oursql:///mydb?use_unicode=0'</span><span class="p">)</span></pre></div>
</div>
<p>To not automatically use <tt class="docutils literal"><span class="pre">utf8</span></tt> and instead use whatever the connection
defaults to, there is a separate parameter:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># use the default connection charset; all strings come back as unicode</span>
<span class="n">create_engine</span><span class="p">(</span><span class="s">'mysql+oursql:///mydb?default_charset=1'</span><span class="p">)</span>
<span class="c"># use latin1 as the connection charset; all strings come back as unicode</span>
<span class="n">create_engine</span><span class="p">(</span><span class="s">'mysql+oursql:///mydb?charset=latin1'</span><span class="p">)</span></pre></div>
</div>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.mysqlconnector">
<span id="mysql-connector-notes"></span><h2>MySQL-Connector Notes<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.mysqlconnector" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via the MySQL Connector/Python adapter.</p>
<p>MySQL Connector/Python is available at:</p>
<blockquote>
<a class="reference external" href="https://launchpad.net/myconnpy">https://launchpad.net/myconnpy</a></blockquote>
<div class="section" id="id4">
<h3>Connecting<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
<p>Connect string format:</p>
<div class="highlight-python"><pre>mysql+mysqlconnector://<user>:<password>@<host>[:<port>]/<dbname></pre>
</div>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.pyodbc">
<span id="pyodbc-notes"></span><h2>pyodbc Notes<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.pyodbc" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via the pyodbc adapter.</p>
<p>pyodbc is available at:</p>
<blockquote>
<a class="reference external" href="http://pypi.python.org/pypi/pyodbc/">http://pypi.python.org/pypi/pyodbc/</a></blockquote>
<div class="section" id="id5">
<h3>Connecting<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h3>
<p>Connect string:</p>
<div class="highlight-python"><pre>mysql+pyodbc://<username>:<password>@<dsnname></pre>
</div>
</div>
<div class="section" id="limitations">
<h3>Limitations<a class="headerlink" href="#limitations" title="Permalink to this headline">¶</a></h3>
<p>The mysql-pyodbc dialect is subject to unresolved character encoding issues
which exist within the current ODBC drivers available.
(see <a class="reference external" href="http://code.google.com/p/pyodbc/issues/detail?id=25">http://code.google.com/p/pyodbc/issues/detail?id=25</a>). Consider usage
of OurSQL, MySQLdb, or MySQL-connector/Python.</p>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.zxjdbc">
<span id="zxjdbc-notes"></span><h2>zxjdbc Notes<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.zxjdbc" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via Jython’s zxjdbc JDBC connector.</p>
<div class="section" id="jdbc-driver">
<h3>JDBC Driver<a class="headerlink" href="#jdbc-driver" title="Permalink to this headline">¶</a></h3>
<p>The official MySQL JDBC driver is at
<a class="reference external" href="http://dev.mysql.com/downloads/connector/j/">http://dev.mysql.com/downloads/connector/j/</a>.</p>
</div>
<div class="section" id="id6">
<h3>Connecting<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h3>
<p>Connect string format:</p>
<blockquote>
mysql+zxjdbc://<user>:<password>@<hostname>[:<port>]/<database></blockquote>
</div>
<div class="section" id="id7">
<h3>Character Sets<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h3>
<p>SQLAlchemy zxjdbc dialects pass unicode straight through to the
zxjdbc/JDBC layer. To allow multiple character sets to be sent from the
MySQL Connector/J JDBC driver, by default SQLAlchemy sets its
<tt class="docutils literal"><span class="pre">characterEncoding</span></tt> connection property to <tt class="docutils literal"><span class="pre">UTF-8</span></tt>. It may be
overriden via a <tt class="docutils literal"><span class="pre">create_engine</span></tt> URL parameter.</p>
</div>
</div>
</div>
</div>
</div>
<div class="bottomnav">
<div class="prevnext">
Previous:
<a href="mssql.html" title="previous chapter">Microsoft SQL Server</a>
Next:
<a href="oracle.html" title="next chapter">Oracle</a>
</div>
<div class="doc_copyright">
© Copyright 2007, 2008, 2009, 2010, the SQLAlchemy authors and contributors.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0b2+.
</div>
</div>
</body>
</html>
|