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 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
MySQL
—
SQLAlchemy 0.9 Documentation
</title>
<!-- begin iterate through SQLA + sphinx environment css_files -->
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/docs.css" type="text/css" />
<link rel="stylesheet" href="../_static/sphinx_paramlinks.css" type="text/css" />
<link rel="stylesheet" href="../_static/changelog.css" type="text/css" />
<!-- end iterate through SQLA + sphinx environment css_files -->
<!-- begin layout.mako headers -->
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.9.8',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html'
};
</script>
<!-- begin iterate through sphinx environment script_files -->
<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>
<!-- end iterate through sphinx environment script_files -->
<script type="text/javascript" src="../_static/detectmobile.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="copyright" title="Copyright" href="../copyright.html" />
<link rel="top" title="SQLAlchemy 0.9 Documentation" href="../index.html" />
<link rel="up" title="Dialects" href="index.html" />
<link rel="next" title="Oracle" href="oracle.html" />
<link rel="prev" title="Microsoft SQL Server" href="mssql.html" />
<!-- end layout.mako headers -->
</head>
<body>
<div id="docs-container">
<div id="docs-top-navigation-container" class="body-background">
<div id="docs-header">
<div id="docs-version-header">
Release: <span class="version-num">0.9.8</span> | Release Date: October 13, 2014
</div>
<h1>SQLAlchemy 0.9 Documentation</h1>
</div>
</div>
<div id="docs-body-container">
<div id="fixed-sidebar" class="withsidebar">
<div id="docs-sidebar-popout">
<h3><a href="../index.html">SQLAlchemy 0.9 Documentation</a></h3>
<p id="sidebar-paginate">
<a href="index.html" title="Dialects">Up</a> |
<a href="mssql.html" title="Microsoft SQL Server">Prev</a> |
<a href="oracle.html" title="Oracle">Next</a>
</p>
<p id="sidebar-topnav">
<a href="../index.html">Contents</a> |
<a href="../genindex.html">Index</a>
</p>
<div id="sidebar-search">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="12" /> <input type="submit" value="Search" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div id="docs-sidebar">
<h3><a href="#">
MySQL
</a></h3>
<ul>
<li><a class="reference internal" href="#">MySQL</a><ul>
<li><a class="reference internal" href="#dialect-mysql">Support for the MySQL database.</a></li>
<li><a class="reference internal" href="#supported-versions-and-features">Supported Versions and Features</a></li>
<li><a class="reference internal" href="#connection-timeouts">Connection Timeouts</a></li>
<li><a class="reference internal" href="#create-table-arguments-including-storage-engines">CREATE TABLE arguments including Storage Engines</a></li>
<li><a class="reference internal" href="#case-sensitivity-and-table-reflection">Case Sensitivity and Table Reflection</a></li>
<li><a class="reference internal" href="#transaction-isolation-level">Transaction Isolation Level</a></li>
<li><a class="reference internal" href="#auto-increment-behavior">AUTO_INCREMENT Behavior</a></li>
<li><a class="reference internal" href="#ansi-quoting-style">Ansi Quoting Style</a></li>
<li><a class="reference internal" href="#mysql-sql-extensions">MySQL SQL Extensions</a></li>
<li><a class="reference internal" href="#rowcount-support">rowcount Support</a></li>
<li><a class="reference internal" href="#cast-support">CAST Support</a></li>
<li><a class="reference internal" href="#mysql-specific-index-options">MySQL Specific Index Options</a><ul>
<li><a class="reference internal" href="#index-length">Index Length</a></li>
<li><a class="reference internal" href="#index-types">Index Types</a></li>
</ul>
</li>
<li><a class="reference internal" href="#mysql-foreign-keys">MySQL Foreign Keys</a><ul>
<li><a class="reference internal" href="#foreign-key-arguments-to-avoid">Foreign Key Arguments to Avoid</a></li>
<li><a class="reference internal" href="#reflection-of-foreign-key-constraints">Reflection of Foreign Key Constraints</a></li>
</ul>
</li>
<li><a class="reference internal" href="#timestamp-columns-and-null">TIMESTAMP Columns and NULL</a></li>
<li><a class="reference internal" href="#mysql-data-types">MySQL Data Types</a></li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.mysqldb">MySQL-Python</a><ul>
<li><a class="reference internal" href="#dialect-mysql-mysqldb-url">DBAPI</a></li>
<li><a class="reference internal" href="#dialect-mysql-mysqldb-connect">Connecting</a></li>
<li><a class="reference internal" href="#unicode">Unicode</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</a><ul>
<li><a class="reference internal" href="#dialect-mysql-oursql-url">DBAPI</a></li>
<li><a class="reference internal" href="#dialect-mysql-oursql-connect">Connecting</a></li>
<li><a class="reference internal" href="#id2">Unicode</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.pymysql">pymysql</a><ul>
<li><a class="reference internal" href="#dialect-mysql-pymysql-url">DBAPI</a></li>
<li><a class="reference internal" href="#dialect-mysql-pymysql-connect">Connecting</a></li>
<li><a class="reference internal" href="#mysql-python-compatibility">MySQL-Python Compatibility</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.mysqlconnector">MySQL-Connector</a><ul>
<li><a class="reference internal" href="#dialect-mysql-mysqlconnector-url">DBAPI</a></li>
<li><a class="reference internal" href="#dialect-mysql-mysqlconnector-connect">Connecting</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.cymysql">cymysql</a><ul>
<li><a class="reference internal" href="#dialect-mysql-cymysql-url">DBAPI</a></li>
<li><a class="reference internal" href="#dialect-mysql-cymysql-connect">Connecting</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.gaerdbms">Google App Engine</a><ul>
<li><a class="reference internal" href="#dialect-mysql-gaerdbms-url">DBAPI</a></li>
<li><a class="reference internal" href="#dialect-mysql-gaerdbms-connect">Connecting</a></li>
<li><a class="reference internal" href="#pooling">Pooling</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sqlalchemy.dialects.mysql.pyodbc">pyodbc</a><ul>
<li><a class="reference internal" href="#dialect-mysql-pyodbc-url">DBAPI</a></li>
<li><a class="reference internal" href="#dialect-mysql-pyodbc-connect">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</a><ul>
<li><a class="reference internal" href="#dialect-mysql-zxjdbc-url">DBAPI</a></li>
<li><a class="reference internal" href="#dialect-mysql-zxjdbc-connect">Connecting</a></li>
<li><a class="reference internal" href="#character-sets">Character Sets</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="docs-body" class="withsidebar" >
<div class="section" id="module-sqlalchemy.dialects.mysql.base">
<span id="mysql"></span><span id="mysql-toplevel"></span><h1>MySQL<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.base" title="Permalink to this headline">¶</a></h1>
<div class="section" id="dialect-mysql">
<p>Support for the MySQL database.</p>
<h2>DBAPI Support<a class="headerlink" href="#dialect-mysql" title="Permalink to this headline">¶</a></h2>
<p>The following dialect/DBAPI options are available. Please refer to individual DBAPI sections for connect information.<ul class="simple">
<li><a class="reference external" href="#module-sqlalchemy.dialects.mysql.mysqldb">MySQL-Python</a></li>
<li><a class="reference external" href="#module-sqlalchemy.dialects.mysql.oursql">OurSQL</a></li>
<li><a class="reference external" href="#module-sqlalchemy.dialects.mysql.pymysql">PyMySQL</a></li>
<li><a class="reference external" href="#module-sqlalchemy.dialects.mysql.mysqlconnector">MySQL Connector/Python</a></li>
<li><a class="reference external" href="#module-sqlalchemy.dialects.mysql.cymysql">CyMySQL</a></li>
<li><a class="reference external" href="#module-sqlalchemy.dialects.mysql.gaerdbms">Google Cloud SQL</a></li>
<li><a class="reference external" href="#module-sqlalchemy.dialects.mysql.pyodbc">PyODBC</a></li>
<li><a class="reference external" href="#module-sqlalchemy.dialects.mysql.zxjdbc">zxjdbc for Jython</a></li>
</ul>
</p>
</div>
<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 MySQL starting with version 4.1 through modern releases.
However, 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>See the official MySQL documentation for detailed information about features
supported in any given server release.</p>
</div>
<div class="section" id="connection-timeouts">
<span id="mysql-connection-timeouts"></span><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="create-table-arguments-including-storage-engines">
<span id="mysql-storage-engines"></span><h2>CREATE TABLE arguments including Storage Engines<a class="headerlink" href="#create-table-arguments-including-storage-engines" title="Permalink to this headline">¶</a></h2>
<p>MySQL’s CREATE TABLE syntax includes a wide array of special options,
including <tt class="docutils literal"><span class="pre">ENGINE</span></tt>, <tt class="docutils literal"><span class="pre">CHARSET</span></tt>, <tt class="docutils literal"><span class="pre">MAX_ROWS</span></tt>, <tt class="docutils literal"><span class="pre">ROW_FORMAT</span></tt>,
<tt class="docutils literal"><span class="pre">INSERT_METHOD</span></tt>, and many more.
To accommodate the rendering of these arguments, specify the form
<tt class="docutils literal"><span class="pre">mysql_argument_name="value"</span></tt>. For example, to specify a table with
<tt class="docutils literal"><span class="pre">ENGINE</span></tt> of <tt class="docutils literal"><span class="pre">InnoDB</span></tt>, <tt class="docutils literal"><span class="pre">CHARSET</span></tt> of <tt class="docutils literal"><span class="pre">utf8</span></tt>, and <tt class="docutils literal"><span class="pre">KEY_BLOCK_SIZE</span></tt>
of <tt class="docutils literal"><span class="pre">1024</span></tt>:</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>
<span class="n">mysql_key_block_size</span><span class="o">=</span><span class="s">"1024"</span>
<span class="p">)</span></pre></div>
</div>
<p>The MySQL dialect will normally transfer any keyword specified as
<tt class="docutils literal"><span class="pre">mysql_keyword_name</span></tt> to be rendered as <tt class="docutils literal"><span class="pre">KEYWORD_NAME</span></tt> in the
<tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">TABLE</span></tt> statement. A handful of these names will render with a space
instead of an underscore; to support this, the MySQL dialect has awareness of
these particular names, which include <tt class="docutils literal"><span class="pre">DATA</span> <span class="pre">DIRECTORY</span></tt>
(e.g. <tt class="docutils literal"><span class="pre">mysql_data_directory</span></tt>), <tt class="docutils literal"><span class="pre">CHARACTER</span> <span class="pre">SET</span></tt> (e.g.
<tt class="docutils literal"><span class="pre">mysql_character_set</span></tt>) and <tt class="docutils literal"><span class="pre">INDEX</span> <span class="pre">DIRECTORY</span></tt> (e.g.
<tt class="docutils literal"><span class="pre">mysql_index_directory</span></tt>).</p>
<p>The most common argument is <tt class="docutils literal"><span class="pre">mysql_engine</span></tt>, which refers to the storage
engine for the table. Historically, MySQL server installations would default
to <tt class="docutils literal"><span class="pre">MyISAM</span></tt> for this value, although newer versions may be defaulting
to <tt class="docutils literal"><span class="pre">InnoDB</span></tt>. The <tt class="docutils literal"><span class="pre">InnoDB</span></tt> engine is typically preferred for its support
of transactions and foreign keys.</p>
<p>A <a class="reference internal" href="../core/metadata.html#sqlalchemy.schema.Table" title="sqlalchemy.schema.Table"><tt class="xref py py-class docutils literal"><span class="pre">Table</span></tt></a> that is created in a MySQL database with a storage engine
of <tt class="docutils literal"><span class="pre">MyISAM</span></tt> will be essentially non-transactional, meaning any
INSERT/UPDATE/DELETE statement referring to this table will be invoked as
autocommit. It also will have no support for foreign key constraints; while
the <tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">TABLE</span></tt> statement accepts foreign key options, when using the
<tt class="docutils literal"><span class="pre">MyISAM</span></tt> storage engine these arguments are discarded. Reflecting such a
table will also produce no foreign key constraint information.</p>
<p>For fully atomic transactions as well as support for foreign key
constraints, all participating <tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">TABLE</span></tt> statements must specify a
transactional engine, which in the vast majority of cases is <tt class="docutils literal"><span class="pre">InnoDB</span></tt>.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference external" href="http://dev.mysql.com/doc/refman/5.0/en/innodb-storage-engine.html">The InnoDB Storage Engine</a> -
on the MySQL website.</p>
</div>
</div>
<div class="section" id="case-sensitivity-and-table-reflection">
<h2>Case Sensitivity and Table Reflection<a class="headerlink" href="#case-sensitivity-and-table-reflection" title="Permalink to this headline">¶</a></h2>
<p>MySQL has inconsistent support for case-sensitive identifier
names, basing support on specific details of the underlying
operating system. However, it has been observed that no matter
what case sensitivity behavior is present, the names of tables in
foreign key declarations are <em>always</em> received from the database
as all-lower case, making it impossible to accurately reflect a
schema where inter-related tables use mixed-case identifier names.</p>
<p>Therefore it is strongly advised that table names be declared as
all lower case both within SQLAlchemy as well as on the MySQL
database itself, especially if database reflection features are
to be used.</p>
</div>
<div class="section" id="transaction-isolation-level">
<span id="mysql-isolation-level"></span><h2>Transaction Isolation Level<a class="headerlink" href="#transaction-isolation-level" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="../core/engines.html#sqlalchemy.create_engine" title="sqlalchemy.create_engine"><tt class="xref py py-func docutils literal"><span class="pre">create_engine()</span></tt></a> accepts an <tt class="docutils literal"><span class="pre">isolation_level</span></tt>
parameter which results in the command <tt class="docutils literal"><span class="pre">SET</span> <span class="pre">SESSION</span>
<span class="pre">TRANSACTION</span> <span class="pre">ISOLATION</span> <span class="pre">LEVEL</span> <span class="pre"><level></span></tt> being invoked for
every new connection. Valid values for this parameter are
<tt class="docutils literal"><span class="pre">READ</span> <span class="pre">COMMITTED</span></tt>, <tt class="docutils literal"><span class="pre">READ</span> <span class="pre">UNCOMMITTED</span></tt>,
<tt class="docutils literal"><span class="pre">REPEATABLE</span> <span class="pre">READ</span></tt>, and <tt class="docutils literal"><span class="pre">SERIALIZABLE</span></tt>:</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"</span><span class="p">,</span>
<span class="n">isolation_level</span><span class="o">=</span><span class="s">"READ UNCOMMITTED"</span>
<span class="p">)</span></pre></div>
</div>
<div class="versionadded">
<p><span>New in version 0.7.6.</span></p>
</div>
</div>
<div class="section" id="auto-increment-behavior">
<h2>AUTO_INCREMENT Behavior<a class="headerlink" href="#auto-increment-behavior" title="Permalink to this headline">¶</a></h2>
<p>When creating tables, SQLAlchemy will automatically set <tt class="docutils literal"><span class="pre">AUTO_INCREMENT</span></tt> on
the first <a class="reference internal" href="../core/types.html#sqlalchemy.types.Integer" title="sqlalchemy.types.Integer"><tt class="xref py py-class docutils literal"><span class="pre">Integer</span></tt></a> primary key column which is not marked as a
foreign key:</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 passing <tt class="docutils literal"><span class="pre">False</span></tt> to the
<a class="reference internal" href="../core/metadata.html#sqlalchemy.schema.Column.params.autoincrement" title="sqlalchemy.schema.Column"><tt class="xref py py-paramref docutils literal"><span class="pre">autoincrement</span></tt></a> argument of <a class="reference internal" href="../core/metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a>. 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="ansi-quoting-style">
<h2>Ansi Quoting Style<a class="headerlink" href="#ansi-quoting-style" title="Permalink to this headline">¶</a></h2>
<p>MySQL features two varieties of identifier “quoting style”, one using
backticks and the other using quotes, e.g. <tt class="docutils literal"><span class="pre">`some_identifier`</span></tt> vs.
<tt class="docutils literal"><span class="pre">"some_identifier"</span></tt>. All MySQL dialects detect which version
is in use by checking the value of <tt class="docutils literal"><span class="pre">sql_mode</span></tt> when a connection is first
established with a particular <a class="reference internal" href="../core/connections.html#sqlalchemy.engine.Engine" title="sqlalchemy.engine.Engine"><tt class="xref py py-class docutils literal"><span class="pre">Engine</span></tt></a>. This quoting style comes
into play when rendering table and column names as well as when reflecting
existing database structures. The detection is entirely automatic and
no special configuration is needed to use either quoting style.</p>
<div class="versionchanged">
<p><span>Changed in version 0.6: </span>detection of ANSI quoting style is entirely automatic,
there’s no longer any end-user <tt class="docutils literal"><span class="pre">create_engine()</span></tt> options in this regard.</p>
</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="rowcount-support">
<h2>rowcount Support<a class="headerlink" href="#rowcount-support" title="Permalink to this headline">¶</a></h2>
<p>SQLAlchemy standardizes the DBAPI <tt class="docutils literal"><span class="pre">cursor.rowcount</span></tt> attribute to be the
usual definition of “number of rows matched by an UPDATE or DELETE” statement.
This is in contradiction to the default setting on most MySQL DBAPI drivers,
which is “number of rows actually modified/deleted”. For this reason, the
SQLAlchemy MySQL dialects always add the <tt class="docutils literal"><span class="pre">constants.CLIENT.FOUND_ROWS</span></tt>
flag, or whatever is equivalent for the target dialect, upon connection.
This setting is currently hardcoded.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="../core/connections.html#sqlalchemy.engine.ResultProxy.rowcount" title="sqlalchemy.engine.ResultProxy.rowcount"><tt class="xref py py-attr docutils literal"><span class="pre">ResultProxy.rowcount</span></tt></a></p>
</div>
</div>
<div class="section" id="cast-support">
<h2>CAST Support<a class="headerlink" href="#cast-support" title="Permalink to this headline">¶</a></h2>
<p>MySQL documents the CAST operator as available in version 4.0.2. When using
the SQLAlchemy <a class="reference internal" href="../core/sqlelement.html#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a> function, SQLAlchemy
will not render the CAST token on MySQL before this version, based on server
version detection, instead rendering the internal expression directly.</p>
<p>CAST may still not be desirable on an early MySQL version post-4.0.2, as it
didn’t add all datatype support until 4.1.1. If your application falls into
this narrow area, the behavior of CAST can be controlled using the
<a class="reference internal" href="../core/compiler.html"><em>Custom SQL Constructs and Compilation Extension</em></a> system, as per the recipe below:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql.expression</span> <span class="kn">import</span> <span class="n">Cast</span>
<span class="kn">from</span> <span class="nn">sqlalchemy.ext.compiler</span> <span class="kn">import</span> <span class="n">compiles</span>
<span class="nd">@compiles</span><span class="p">(</span><span class="n">Cast</span><span class="p">,</span> <span class="s">'mysql'</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">_check_mysql_version</span><span class="p">(</span><span class="n">element</span><span class="p">,</span> <span class="n">compiler</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">):</span>
<span class="k">if</span> <span class="n">compiler</span><span class="o">.</span><span class="n">dialect</span><span class="o">.</span><span class="n">server_version_info</span> <span class="o"><</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span>
<span class="k">return</span> <span class="n">compiler</span><span class="o">.</span><span class="n">process</span><span class="p">(</span><span class="n">element</span><span class="o">.</span><span class="n">clause</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">compiler</span><span class="o">.</span><span class="n">visit_cast</span><span class="p">(</span><span class="n">element</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">)</span></pre></div>
</div>
<p>The above function, which only needs to be declared once
within an application, overrides the compilation of the
<a class="reference internal" href="../core/sqlelement.html#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a> construct to check for version 4.1.0 before
fully rendering CAST; else the internal element of the
construct is rendered directly.</p>
</div>
<div class="section" id="mysql-specific-index-options">
<span id="mysql-indexes"></span><h2>MySQL Specific Index Options<a class="headerlink" href="#mysql-specific-index-options" title="Permalink to this headline">¶</a></h2>
<p>MySQL-specific extensions to the <a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.Index" title="sqlalchemy.schema.Index"><tt class="xref py py-class docutils literal"><span class="pre">Index</span></tt></a> construct are available.</p>
<div class="section" id="index-length">
<h3>Index Length<a class="headerlink" href="#index-length" title="Permalink to this headline">¶</a></h3>
<p>MySQL provides an option to create index entries with a certain length, where
“length” refers to the number of characters or bytes in each value which will
become part of the index. SQLAlchemy provides this feature via the
<tt class="docutils literal"><span class="pre">mysql_length</span></tt> parameter:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Index</span><span class="p">(</span><span class="s">'my_index'</span><span class="p">,</span> <span class="n">my_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">data</span><span class="p">,</span> <span class="n">mysql_length</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="n">Index</span><span class="p">(</span><span class="s">'a_b_idx'</span><span class="p">,</span> <span class="n">my_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">a</span><span class="p">,</span> <span class="n">my_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">b</span><span class="p">,</span> <span class="n">mysql_length</span><span class="o">=</span><span class="p">{</span><span class="s">'a'</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="s">'b'</span><span class="p">:</span> <span class="mi">9</span><span class="p">})</span></pre></div>
</div>
<p>Prefix lengths are given in characters for nonbinary string types and in bytes
for binary string types. The value passed to the keyword argument <em>must</em> be
either an integer (and, thus, specify the same prefix length value for all
columns of the index) or a dict in which keys are column names and values are
prefix length values for corresponding columns. MySQL only allows a length for
a column of an index if it is for a CHAR, VARCHAR, TEXT, BINARY, VARBINARY and
BLOB.</p>
<div class="versionadded">
<p><span>New in version 0.8.2: </span><tt class="docutils literal"><span class="pre">mysql_length</span></tt> may now be specified as a dictionary
for use with composite indexes.</p>
</div>
</div>
<div class="section" id="index-types">
<h3>Index Types<a class="headerlink" href="#index-types" title="Permalink to this headline">¶</a></h3>
<p>Some MySQL storage engines permit you to specify an index type when creating
an index or primary key constraint. SQLAlchemy provides this feature via the
<tt class="docutils literal"><span class="pre">mysql_using</span></tt> parameter on <a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.Index" title="sqlalchemy.schema.Index"><tt class="xref py py-class docutils literal"><span class="pre">Index</span></tt></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Index</span><span class="p">(</span><span class="s">'my_index'</span><span class="p">,</span> <span class="n">my_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">data</span><span class="p">,</span> <span class="n">mysql_using</span><span class="o">=</span><span class="s">'hash'</span><span class="p">)</span></pre></div>
</div>
<p>As well as the <tt class="docutils literal"><span class="pre">mysql_using</span></tt> parameter on <a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.PrimaryKeyConstraint" title="sqlalchemy.schema.PrimaryKeyConstraint"><tt class="xref py py-class docutils literal"><span class="pre">PrimaryKeyConstraint</span></tt></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">PrimaryKeyConstraint</span><span class="p">(</span><span class="s">"data"</span><span class="p">,</span> <span class="n">mysql_using</span><span class="o">=</span><span class="s">'hash'</span><span class="p">)</span></pre></div>
</div>
<p>The value passed to the keyword argument will be simply passed through to the
underlying CREATE INDEX or PRIMARY KEY clause, so it <em>must</em> be a valid index
type for your MySQL storage engine.</p>
<p>More information can be found at:</p>
<p><a class="reference external" href="http://dev.mysql.com/doc/refman/5.0/en/create-index.html">http://dev.mysql.com/doc/refman/5.0/en/create-index.html</a></p>
<p><a class="reference external" href="http://dev.mysql.com/doc/refman/5.0/en/create-table.html">http://dev.mysql.com/doc/refman/5.0/en/create-table.html</a></p>
</div>
</div>
<div class="section" id="mysql-foreign-keys">
<span id="id1"></span><h2>MySQL Foreign Keys<a class="headerlink" href="#mysql-foreign-keys" title="Permalink to this headline">¶</a></h2>
<p>MySQL’s behavior regarding foreign keys has some important caveats.</p>
<div class="section" id="foreign-key-arguments-to-avoid">
<h3>Foreign Key Arguments to Avoid<a class="headerlink" href="#foreign-key-arguments-to-avoid" title="Permalink to this headline">¶</a></h3>
<p>MySQL does not support the foreign key arguments “DEFERRABLE”, “INITIALLY”,
or “MATCH”. Using the <tt class="docutils literal"><span class="pre">deferrable</span></tt> or <tt class="docutils literal"><span class="pre">initially</span></tt> keyword argument with
<a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.ForeignKeyConstraint" title="sqlalchemy.schema.ForeignKeyConstraint"><tt class="xref py py-class docutils literal"><span class="pre">ForeignKeyConstraint</span></tt></a> or <a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.ForeignKey" title="sqlalchemy.schema.ForeignKey"><tt class="xref py py-class docutils literal"><span class="pre">ForeignKey</span></tt></a> will have the effect of
these keywords being rendered in a DDL expression, which will then raise an
error on MySQL. In order to use these keywords on a foreign key while having
them ignored on a MySQL backend, use a custom compile rule:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.ext.compiler</span> <span class="kn">import</span> <span class="n">compiles</span>
<span class="kn">from</span> <span class="nn">sqlalchemy.schema</span> <span class="kn">import</span> <span class="n">ForeignKeyConstraint</span>
<span class="nd">@compiles</span><span class="p">(</span><span class="n">ForeignKeyConstraint</span><span class="p">,</span> <span class="s">"mysql"</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">process</span><span class="p">(</span><span class="n">element</span><span class="p">,</span> <span class="n">compiler</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">):</span>
<span class="n">element</span><span class="o">.</span><span class="n">deferrable</span> <span class="o">=</span> <span class="n">element</span><span class="o">.</span><span class="n">initially</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">return</span> <span class="n">compiler</span><span class="o">.</span><span class="n">visit_foreign_key_constraint</span><span class="p">(</span><span class="n">element</span><span class="p">,</span> <span class="o">**</span><span class="n">kw</span><span class="p">)</span></pre></div>
</div>
<div class="versionchanged">
<p><span>Changed in version 0.9.0: </span>- the MySQL backend no longer silently ignores
the <tt class="docutils literal"><span class="pre">deferrable</span></tt> or <tt class="docutils literal"><span class="pre">initially</span></tt> keyword arguments of
<a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.ForeignKeyConstraint" title="sqlalchemy.schema.ForeignKeyConstraint"><tt class="xref py py-class docutils literal"><span class="pre">ForeignKeyConstraint</span></tt></a> and <a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.ForeignKey" title="sqlalchemy.schema.ForeignKey"><tt class="xref py py-class docutils literal"><span class="pre">ForeignKey</span></tt></a>.</p>
</div>
<p>The “MATCH” keyword is in fact more insidious, and is explicitly disallowed
by SQLAlchemy in conjunction with the MySQL backend. This argument is
silently ignored by MySQL, but in addition has the effect of ON UPDATE and ON
DELETE options also being ignored by the backend. Therefore MATCH should
never be used with the MySQL backend; as is the case with DEFERRABLE and
INITIALLY, custom compilation rules can be used to correct a MySQL
ForeignKeyConstraint at DDL definition time.</p>
<div class="versionadded">
<p><span>New in version 0.9.0: </span>- the MySQL backend will raise a
<tt class="xref py py-class docutils literal"><span class="pre">CompileError</span></tt> when the <tt class="docutils literal"><span class="pre">match</span></tt> keyword is used with
<a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.ForeignKeyConstraint" title="sqlalchemy.schema.ForeignKeyConstraint"><tt class="xref py py-class docutils literal"><span class="pre">ForeignKeyConstraint</span></tt></a> or <a class="reference internal" href="../core/constraints.html#sqlalchemy.schema.ForeignKey" title="sqlalchemy.schema.ForeignKey"><tt class="xref py py-class docutils literal"><span class="pre">ForeignKey</span></tt></a>.</p>
</div>
</div>
<div class="section" id="reflection-of-foreign-key-constraints">
<h3>Reflection of Foreign Key Constraints<a class="headerlink" href="#reflection-of-foreign-key-constraints" title="Permalink to this headline">¶</a></h3>
<p>Not all MySQL storage engines support foreign keys. When using the
very common <tt class="docutils literal"><span class="pre">MyISAM</span></tt> MySQL storage engine, 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>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#mysql-storage-engines"><em>CREATE TABLE arguments including Storage Engines</em></a></p>
</div>
</div>
</div>
<div class="section" id="timestamp-columns-and-null">
<span id="mysql-timestamp-null"></span><h2>TIMESTAMP Columns and NULL<a class="headerlink" href="#timestamp-columns-and-null" title="Permalink to this headline">¶</a></h2>
<p>MySQL enforces that a column which specifies the TIMESTAMP datatype implicitly
includes a default value of CURRENT_TIMESTAMP, even though this is not
stated, and additionally sets the column as NOT NULL, the opposite behavior
vs. that of all other datatypes:</p>
<div class="highlight-python"><pre>mysql> CREATE TABLE ts_test (
-> a INTEGER,
-> b INTEGER NOT NULL,
-> c TIMESTAMP,
-> d TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
-> e TIMESTAMP NULL);
Query OK, 0 rows affected (0.03 sec)
mysql> SHOW CREATE TABLE ts_test;
+---------+-----------------------------------------------------
| Table | Create Table
+---------+-----------------------------------------------------
| ts_test | CREATE TABLE `ts_test` (
`a` int(11) DEFAULT NULL,
`b` int(11) NOT NULL,
`c` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`d` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`e` timestamp NULL DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1</pre>
</div>
<p>Above, we see that an INTEGER column defaults to NULL, unless it is specified
with NOT NULL. But when the column is of type TIMESTAMP, an implicit
default of CURRENT_TIMESTAMP is generated which also coerces the column
to be a NOT NULL, even though we did not specify it as such.</p>
<p>Therefore, the usual “NOT NULL” clause <em>does not apply</em> to a TIMESTAMP
column; MySQL selects this implicitly. SQLAlchemy therefore does not render
NOT NULL for a TIMESTAMP column on MySQL. However, it <em>does</em> render
NULL when we specify nullable=True, or if we leave nullable absent, as it
also defaults to True. This is to accommodate the essentially
reverse behavior of the NULL flag for TIMESTAMP:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy</span> <span class="kn">import</span> <span class="n">MetaData</span><span class="p">,</span> <span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">Integer</span><span class="p">,</span> <span class="n">Table</span><span class="p">,</span> <span class="n">Column</span><span class="p">,</span> <span class="n">text</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">MetaData</span><span class="p">()</span>
<span class="n">t</span> <span class="o">=</span> <span class="n">Table</span><span class="p">(</span><span class="s">'ts_test'</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'a'</span><span class="p">,</span> <span class="n">Integer</span><span class="p">),</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'b'</span><span class="p">,</span> <span class="n">Integer</span><span class="p">,</span> <span class="n">nullable</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">'c'</span><span class="p">,</span> <span class="n">TIMESTAMP</span><span class="p">),</span>
<span class="n">Column</span><span class="p">(</span><span class="s">'d'</span><span class="p">,</span> <span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">nullable</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">'e'</span><span class="p">,</span> <span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">nullable</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="p">)</span>
<span class="kn">from</span> <span class="nn">sqlalchemy</span> <span class="kn">import</span> <span class="n">create_engine</span>
<span class="n">e</span> <span class="o">=</span> <span class="n">create_engine</span><span class="p">(</span><span class="s">"mysql://scott:tiger@localhost/test"</span><span class="p">,</span> <span class="n">echo</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">m</span><span class="o">.</span><span class="n">create_all</span><span class="p">(</span><span class="n">e</span><span class="p">)</span></pre></div>
</div>
<p>In the output, we can see that the TIMESTAMP column receives a different
treatment for NULL / NOT NULL vs. that of the INTEGER:</p>
<div class="highlight-python"><pre>CREATE TABLE ts_test (
a INTEGER,
b INTEGER NOT NULL,
c TIMESTAMP NULL,
d TIMESTAMP,
e TIMESTAMP NULL
)</pre>
</div>
<p>MySQL above receives the NULL/NOT NULL constraint as is stated in our
original <a class="reference internal" href="../core/metadata.html#sqlalchemy.schema.Table" title="sqlalchemy.schema.Table"><tt class="xref py py-class docutils literal"><span class="pre">Table</span></tt></a>:</p>
<div class="highlight-python"><pre>mysql> SHOW CREATE TABLE ts_test;
+---------+---------------------------
| Table | Create Table
+---------+---------------------------
| ts_test | CREATE TABLE `ts_test` (
`a` int(11) DEFAULT NULL,
`b` int(11) NOT NULL,
`c` timestamp NULL DEFAULT NULL,
`d` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`e` timestamp NULL DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1</pre>
</div>
<p>Be sure to always favor the <tt class="docutils literal"><span class="pre">SHOW</span> <span class="pre">CREATE</span> <span class="pre">TABLE</span></tt> output over the
SQLAlchemy-emitted DDL when checking table definitions, as MySQL’s
rules can be hard to predict.</p>
</div>
<div class="section" id="mysql-data-types">
<h2>MySQL Data Types<a class="headerlink" href="#mysql-data-types" title="Permalink to this headline">¶</a></h2>
<p>As with all SQLAlchemy dialects, all UPPERCASE types that are known to be
valid with MySQL are importable from the top level dialect:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.dialects.mysql</span> <span class="kn">import</span> \
<span class="n">BIGINT</span><span class="p">,</span> <span class="n">BINARY</span><span class="p">,</span> <span class="n">BIT</span><span class="p">,</span> <span class="n">BLOB</span><span class="p">,</span> <span class="n">BOOLEAN</span><span class="p">,</span> <span class="n">CHAR</span><span class="p">,</span> <span class="n">DATE</span><span class="p">,</span> \
<span class="n">DATETIME</span><span class="p">,</span> <span class="n">DECIMAL</span><span class="p">,</span> <span class="n">DECIMAL</span><span class="p">,</span> <span class="n">DOUBLE</span><span class="p">,</span> <span class="n">ENUM</span><span class="p">,</span> <span class="n">FLOAT</span><span class="p">,</span> <span class="n">INTEGER</span><span class="p">,</span> \
<span class="n">LONGBLOB</span><span class="p">,</span> <span class="n">LONGTEXT</span><span class="p">,</span> <span class="n">MEDIUMBLOB</span><span class="p">,</span> <span class="n">MEDIUMINT</span><span class="p">,</span> <span class="n">MEDIUMTEXT</span><span class="p">,</span> <span class="n">NCHAR</span><span class="p">,</span> \
<span class="n">NUMERIC</span><span class="p">,</span> <span class="n">NVARCHAR</span><span class="p">,</span> <span class="n">REAL</span><span class="p">,</span> <span class="n">SET</span><span class="p">,</span> <span class="n">SMALLINT</span><span class="p">,</span> <span class="n">TEXT</span><span class="p">,</span> <span class="n">TIME</span><span class="p">,</span> <span class="n">TIMESTAMP</span><span class="p">,</span> \
<span class="n">TINYBLOB</span><span class="p">,</span> <span class="n">TINYINT</span><span class="p">,</span> <span class="n">TINYTEXT</span><span class="p">,</span> <span class="n">VARBINARY</span><span class="p">,</span> <span class="n">VARCHAR</span><span class="p">,</span> <span class="n">YEAR</span></pre></div>
</div>
<p>Types which are specific to MySQL, or have MySQL-specific
construction arguments, are as follows:</p>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.BIGINT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.BIGINT.params.display_width"></span><strong>display_width</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.BIGINT.params.display_width">¶</a> – Optional, maximum display width for this number.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.BIGINT.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.BIGINT.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.BIGINT.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.BIGINT.params.zerofill">¶</a> – 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.BINARY">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">BINARY</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.BIT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">BIT</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.BIT" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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.BIT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><span class="target" id="sqlalchemy.dialects.mysql.BIT.params.length"></span><strong>length</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.BIT.params.length">¶</a> – Optional, number of bits.</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.BLOB">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">BLOB</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.BLOB" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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.BLOB.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><span class="target" id="sqlalchemy.dialects.mysql.BLOB.params.length"></span><strong>length</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.BLOB.params.length">¶</a> – 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.</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.BOOLEAN">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.BOOLEAN" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.BOOLEAN.params.create_constraint"></span><strong>create_constraint</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.BOOLEAN.params.create_constraint">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.BOOLEAN.params.name"></span><strong>name</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.BOOLEAN.params.name">¶</a> – if a CHECK constraint is generated, specify
the name of the constraint.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.CHAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">CHAR</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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="../core/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.CHAR.__init__">
<tt class="descname">__init__</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.CHAR.params.length"></span><strong>length</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.CHAR.params.length">¶</a> – Maximum data length, in characters.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.CHAR.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.CHAR.params.binary">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.CHAR.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.CHAR.params.collation">¶</a> – 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.DATE">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">DATE</tt><a class="headerlink" href="#sqlalchemy.dialects.mysql.DATE" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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="attribute">
<dt id="sqlalchemy.dialects.mysql.DATE.__init__">
<tt class="descname">__init__</tt><a class="headerlink" href="#sqlalchemy.dialects.mysql.DATE.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>x.__init__(...) initializes x; see help(type(x)) for signature</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.DATETIME">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">DATETIME</tt><big>(</big><em>timezone=False</em>, <em>fsp=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.DATETIME" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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>MySQL DATETIME type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.DATETIME.__init__">
<tt class="descname">__init__</tt><big>(</big><em>timezone=False</em>, <em>fsp=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.DATETIME.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a MySQL DATETIME 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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.DATETIME.params.timezone"></span><strong>timezone</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DATETIME.params.timezone">¶</a> – not used by the MySQL dialect.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.DATETIME.params.fsp"></span><strong>fsp</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DATETIME.params.fsp">¶</a> – <p>fractional seconds precision value.
MySQL 5.6.4 supports storage of fractional seconds;
this parameter will be used when emitting DDL
for the DATETIME type.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">DBAPI driver support for fractional seconds may
be limited; current support includes
MySQL Connector/Python.</p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span>New in version 0.8.5: </span>Added MySQL-specific <a class="reference internal" href="#sqlalchemy.dialects.mysql.DATETIME" title="sqlalchemy.dialects.mysql.DATETIME"><tt class="xref py py-class docutils literal"><span class="pre">mysql.DATETIME</span></tt></a>
with fractional seconds support.</p>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.DECIMAL">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.DECIMAL.params.precision"></span><strong>precision</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DECIMAL.params.precision">¶</a> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.DECIMAL.params.scale"></span><strong>scale</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DECIMAL.params.scale">¶</a> – The number of digits after the decimal point.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.DECIMAL.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DECIMAL.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.DECIMAL.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DECIMAL.params.zerofill">¶</a> – 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.DOUBLE">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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.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.DOUBLE.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a DOUBLE.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <a class="reference internal" href="#sqlalchemy.dialects.mysql.DOUBLE" title="sqlalchemy.dialects.mysql.DOUBLE"><tt class="xref py py-class docutils literal"><span class="pre">DOUBLE</span></tt></a> type by default converts from float
to Decimal, using a truncation that defaults to 10 digits.
Specify either <tt class="docutils literal"><span class="pre">scale=n</span></tt> or <tt class="docutils literal"><span class="pre">decimal_return_scale=n</span></tt> in order
to change this scale, or <tt class="docutils literal"><span class="pre">asdecimal=False</span></tt> to return values
directly as Python floating points.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.DOUBLE.params.precision"></span><strong>precision</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DOUBLE.params.precision">¶</a> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.DOUBLE.params.scale"></span><strong>scale</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DOUBLE.params.scale">¶</a> – The number of digits after the decimal point.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.DOUBLE.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DOUBLE.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.DOUBLE.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.DOUBLE.params.zerofill">¶</a> – 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.ENUM">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">ENUM</tt><big>(</big><em>*enums</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.ENUM" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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._EnumeratedValues</span></tt></p>
<p>MySQL ENUM type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.ENUM.__init__">
<tt class="descname">__init__</tt><big>(</big><em>*enums</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.ENUM.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct an ENUM.</p>
<p>E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Column</span><span class="p">(</span><span class="s">'myenum'</span><span class="p">,</span> <span class="n">ENUM</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>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.ENUM.params.enums"></span><strong>enums</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.ENUM.params.enums">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.ENUM.params.strict"></span><strong>strict</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.ENUM.params.strict">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.ENUM.params.charset"></span><strong>charset</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.ENUM.params.charset">¶</a> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.ENUM.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.ENUM.params.collation">¶</a> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.ENUM.params.ascii"></span><strong>ascii</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.ENUM.params.ascii">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.ENUM.params.unicode"></span><strong>unicode</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.ENUM.params.unicode">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.ENUM.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.ENUM.params.binary">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.ENUM.params.quoting"></span><strong>quoting</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.ENUM.params.quoting">¶</a> – <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.FLOAT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.FLOAT.params.precision"></span><strong>precision</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.FLOAT.params.precision">¶</a> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.FLOAT.params.scale"></span><strong>scale</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.FLOAT.params.scale">¶</a> – The number of digits after the decimal point.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.FLOAT.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.FLOAT.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.FLOAT.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.FLOAT.params.zerofill">¶</a> – 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.INTEGER">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.INTEGER.params.display_width"></span><strong>display_width</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.INTEGER.params.display_width">¶</a> – Optional, maximum display width for this number.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.INTEGER.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.INTEGER.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.INTEGER.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.INTEGER.params.zerofill">¶</a> – 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.LONGBLOB">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">LONGBLOB</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.LONGTEXT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">LONGTEXT</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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.LONGTEXT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.LONGTEXT.params.charset"></span><strong>charset</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.LONGTEXT.params.charset">¶</a> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.LONGTEXT.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.LONGTEXT.params.collation">¶</a> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.LONGTEXT.params.ascii"></span><strong>ascii</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.LONGTEXT.params.ascii">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.LONGTEXT.params.unicode"></span><strong>unicode</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.LONGTEXT.params.unicode">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.LONGTEXT.params.national"></span><strong>national</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.LONGTEXT.params.national">¶</a> – Optional. If true, use the server’s configured
national character set.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.LONGTEXT.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.LONGTEXT.params.binary">¶</a> – 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.MEDIUMBLOB">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">MEDIUMBLOB</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.MEDIUMINT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMINT.params.display_width"></span><strong>display_width</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMINT.params.display_width">¶</a> – Optional, maximum display width for this number.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMINT.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMINT.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMINT.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMINT.params.zerofill">¶</a> – 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.MEDIUMTEXT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">MEDIUMTEXT</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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.MEDIUMTEXT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMTEXT.params.charset"></span><strong>charset</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMTEXT.params.charset">¶</a> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMTEXT.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMTEXT.params.collation">¶</a> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMTEXT.params.ascii"></span><strong>ascii</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMTEXT.params.ascii">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMTEXT.params.unicode"></span><strong>unicode</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMTEXT.params.unicode">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMTEXT.params.national"></span><strong>national</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMTEXT.params.national">¶</a> – Optional. If true, use the server’s configured
national character set.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.MEDIUMTEXT.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.MEDIUMTEXT.params.binary">¶</a> – 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.NCHAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">NCHAR</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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="../core/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.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.NCHAR.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct an NCHAR.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.NCHAR.params.length"></span><strong>length</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NCHAR.params.length">¶</a> – Maximum data length, in characters.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.NCHAR.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NCHAR.params.binary">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.NCHAR.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NCHAR.params.collation">¶</a> – 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.NUMERIC">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.NUMERIC.params.precision"></span><strong>precision</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NUMERIC.params.precision">¶</a> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.NUMERIC.params.scale"></span><strong>scale</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NUMERIC.params.scale">¶</a> – The number of digits after the decimal point.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.NUMERIC.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NUMERIC.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.NUMERIC.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NUMERIC.params.zerofill">¶</a> – 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.NVARCHAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">NVARCHAR</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.NVARCHAR.params.length"></span><strong>length</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NVARCHAR.params.length">¶</a> – Maximum data length, in characters.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.NVARCHAR.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NVARCHAR.params.binary">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.NVARCHAR.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.NVARCHAR.params.collation">¶</a> – 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.REAL">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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>, <a class="reference internal" href="../core/types.html#sqlalchemy.types.REAL" title="sqlalchemy.types.REAL"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.types.REAL</span></tt></a></p>
<p>MySQL REAL type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.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.REAL.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a REAL.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <a class="reference internal" href="#sqlalchemy.dialects.mysql.REAL" title="sqlalchemy.dialects.mysql.REAL"><tt class="xref py py-class docutils literal"><span class="pre">REAL</span></tt></a> type by default converts from float
to Decimal, using a truncation that defaults to 10 digits.
Specify either <tt class="docutils literal"><span class="pre">scale=n</span></tt> or <tt class="docutils literal"><span class="pre">decimal_return_scale=n</span></tt> in order
to change this scale, or <tt class="docutils literal"><span class="pre">asdecimal=False</span></tt> to return values
directly as Python floating points.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.REAL.params.precision"></span><strong>precision</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.REAL.params.precision">¶</a> – Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.REAL.params.scale"></span><strong>scale</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.REAL.params.scale">¶</a> – The number of digits after the decimal point.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.REAL.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.REAL.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.REAL.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.REAL.params.zerofill">¶</a> – 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.SET">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">SET</tt><big>(</big><em>*values</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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._EnumeratedValues</span></tt></p>
<p>MySQL SET type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.SET.__init__">
<tt class="descname">__init__</tt><big>(</big><em>*values</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.SET.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a SET.</p>
<p>E.g.:</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">SET</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>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.SET.params.values"></span><strong>values</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SET.params.values">¶</a> – <p>The range of valid values for this SET. Values will be
quoted when generating the schema according to the quoting flag (see
below).</p>
<div class="versionchanged">
<p><span>Changed in version 0.9.0: </span>quoting is applied automatically to
<a class="reference internal" href="#sqlalchemy.dialects.mysql.SET" title="sqlalchemy.dialects.mysql.SET"><tt class="xref py py-class docutils literal"><span class="pre">mysql.SET</span></tt></a> in the same way as for <a class="reference internal" href="#sqlalchemy.dialects.mysql.ENUM" title="sqlalchemy.dialects.mysql.ENUM"><tt class="xref py py-class docutils literal"><span class="pre">mysql.ENUM</span></tt></a>.</p>
</div>
</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.SET.params.charset"></span><strong>charset</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SET.params.charset">¶</a> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.SET.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SET.params.collation">¶</a> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.SET.params.ascii"></span><strong>ascii</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SET.params.ascii">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.SET.params.unicode"></span><strong>unicode</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SET.params.unicode">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.SET.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SET.params.binary">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.SET.params.quoting"></span><strong>quoting</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SET.params.quoting">¶</a> – <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>
<div class="versionadded">
<p><span>New in version 0.9.0.</span></p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.SMALLINT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.SMALLINT.params.display_width"></span><strong>display_width</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SMALLINT.params.display_width">¶</a> – Optional, maximum display width for this number.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.SMALLINT.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SMALLINT.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.SMALLINT.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.SMALLINT.params.zerofill">¶</a> – 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.TEXT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">TEXT</tt><big>(</big><em>length=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.TEXT.params.length"></span><strong>length</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TEXT.params.length">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.TEXT.params.charset"></span><strong>charset</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TEXT.params.charset">¶</a> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TEXT.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TEXT.params.collation">¶</a> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TEXT.params.ascii"></span><strong>ascii</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TEXT.params.ascii">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.TEXT.params.unicode"></span><strong>unicode</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TEXT.params.unicode">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.TEXT.params.national"></span><strong>national</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TEXT.params.national">¶</a> – Optional. If true, use the server’s configured
national character set.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TEXT.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TEXT.params.binary">¶</a> – 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.TIME">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">TIME</tt><big>(</big><em>timezone=False</em>, <em>fsp=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.TIME" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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>MySQL TIME type.</p>
<dl class="method">
<dt id="sqlalchemy.dialects.mysql.TIME.__init__">
<tt class="descname">__init__</tt><big>(</big><em>timezone=False</em>, <em>fsp=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.TIME.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a MySQL TIME 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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.TIME.params.timezone"></span><strong>timezone</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TIME.params.timezone">¶</a> – not used by the MySQL dialect.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TIME.params.fsp"></span><strong>fsp</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TIME.params.fsp">¶</a> – <p>fractional seconds precision value.
MySQL 5.6 supports storage of fractional seconds;
this parameter will be used when emitting DDL
for the TIME type.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">DBAPI driver support for fractional seconds may
be limited; current support includes
MySQL Connector/Python.</p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span>New in version 0.8: </span>The MySQL-specific TIME
type as well as fractional seconds support.</p>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.TIMESTAMP">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">TIMESTAMP</tt><big>(</big><em>timezone=False</em>, <em>fsp=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.TIMESTAMP" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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.TIMESTAMP.__init__">
<tt class="descname">__init__</tt><big>(</big><em>timezone=False</em>, <em>fsp=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.TIMESTAMP.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a MySQL TIMESTAMP 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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.TIMESTAMP.params.timezone"></span><strong>timezone</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TIMESTAMP.params.timezone">¶</a> – not used by the MySQL dialect.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TIMESTAMP.params.fsp"></span><strong>fsp</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TIMESTAMP.params.fsp">¶</a> – <p>fractional seconds precision value.
MySQL 5.6.4 supports storage of fractional seconds;
this parameter will be used when emitting DDL
for the TIMESTAMP type.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">DBAPI driver support for fractional seconds may
be limited; current support includes
MySQL Connector/Python.</p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span>New in version 0.8.5: </span>Added MySQL-specific <a class="reference internal" href="#sqlalchemy.dialects.mysql.TIMESTAMP" title="sqlalchemy.dialects.mysql.TIMESTAMP"><tt class="xref py py-class docutils literal"><span class="pre">mysql.TIMESTAMP</span></tt></a>
with fractional seconds support.</p>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.TINYBLOB">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">TINYBLOB</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.TINYINT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</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.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.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.TINYINT.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a TINYINT.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.TINYINT.params.display_width"></span><strong>display_width</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYINT.params.display_width">¶</a> – Optional, maximum display width for this number.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TINYINT.params.unsigned"></span><strong>unsigned</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYINT.params.unsigned">¶</a> – a boolean, optional.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TINYINT.params.zerofill"></span><strong>zerofill</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYINT.params.zerofill">¶</a> – 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.TINYTEXT">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">TINYTEXT</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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.TINYTEXT.__init__">
<tt class="descname">__init__</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.TINYTEXT.params.charset"></span><strong>charset</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYTEXT.params.charset">¶</a> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TINYTEXT.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYTEXT.params.collation">¶</a> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TINYTEXT.params.ascii"></span><strong>ascii</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYTEXT.params.ascii">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.TINYTEXT.params.unicode"></span><strong>unicode</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYTEXT.params.unicode">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.TINYTEXT.params.national"></span><strong>national</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYTEXT.params.national">¶</a> – Optional. If true, use the server’s configured
national character set.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.TINYTEXT.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.TINYTEXT.params.binary">¶</a> – 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.VARBINARY">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">VARBINARY</tt><big>(</big><em>length=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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>
</dd></dl>
<dl class="class">
<dt id="sqlalchemy.dialects.mysql.VARCHAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">VARCHAR</tt><big>(</big><em>length=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.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="../core/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.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.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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="sqlalchemy.dialects.mysql.VARCHAR.params.charset"></span><strong>charset</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.VARCHAR.params.charset">¶</a> – Optional, a column-level character set for this string
value. Takes precedence to ‘ascii’ or ‘unicode’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.VARCHAR.params.collation"></span><strong>collation</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.VARCHAR.params.collation">¶</a> – Optional, a column-level collation for this string
value. Takes precedence to ‘binary’ short-hand.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.VARCHAR.params.ascii"></span><strong>ascii</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.VARCHAR.params.ascii">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.VARCHAR.params.unicode"></span><strong>unicode</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.VARCHAR.params.unicode">¶</a> – 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><span class="target" id="sqlalchemy.dialects.mysql.VARCHAR.params.national"></span><strong>national</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.VARCHAR.params.national">¶</a> – Optional. If true, use the server’s configured
national character set.</li>
<li><span class="target" id="sqlalchemy.dialects.mysql.VARCHAR.params.binary"></span><strong>binary</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.dialects.mysql.VARCHAR.params.binary">¶</a> – 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.YEAR">
<em class="property">class </em><tt class="descclassname">sqlalchemy.dialects.mysql.</tt><tt class="descname">YEAR</tt><big>(</big><em>display_width=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.dialects.mysql.YEAR" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="../core/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>
</dd></dl>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.mysqldb">
<span id="mysql-python"></span><h2>MySQL-Python<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 driver.</p>
<div class="section" id="dialect-mysql-mysqldb-url">
<h3>DBAPI<a class="headerlink" href="#dialect-mysql-mysqldb-url" title="Permalink to this headline">¶</a></h3>
<p>Documentation and download information (if applicable) for MySQL-Python is available at:
<a class="reference external" href="http://sourceforge.net/projects/mysql-python">http://sourceforge.net/projects/mysql-python</a></p>
</div>
<div class="section" id="dialect-mysql-mysqldb-connect">
<h3>Connecting<a class="headerlink" href="#dialect-mysql-mysqldb-connect" title="Permalink to this headline">¶</a></h3>
<p>Connect String:<div class="highlight-python"><pre>mysql+mysqldb://<user>:<password>@<host>[:<port>]/<dbname></pre>
</div>
</p>
</div>
<div class="section" id="unicode">
<h3>Unicode<a class="headerlink" href="#unicode" title="Permalink to this headline">¶</a></h3>
<p>MySQLdb requires a “charset” parameter to be passed in order for it
to handle non-ASCII characters correctly. When this parameter is passed,
MySQLdb will also implicitly set the “use_unicode” flag to true, which means
that it will return Python unicode objects instead of bytestrings.
However, SQLAlchemy’s decode process, when C extensions are enabled,
is orders of magnitude faster than that of MySQLdb as it does not call into
Python functions to do so. Therefore, the <strong>recommended URL to use for
unicode</strong> will include both charset and use_unicode=0:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">create_engine</span><span class="p">(</span><span class="s">"mysql+mysqldb://user:pass@host/dbname?charset=utf8&use_unicode=0"</span><span class="p">)</span></pre></div>
</div>
<p>As of this writing, MySQLdb only runs on Python 2. It is not known how
MySQLdb behaves on Python 3 as far as unicode decoding.</p>
</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 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>.
It is strongly advised to use the latest version of MySQL-Python.</p>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.oursql">
<span id="oursql"></span><h2>OurSQL<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 driver.</p>
<div class="section" id="dialect-mysql-oursql-url">
<h3>DBAPI<a class="headerlink" href="#dialect-mysql-oursql-url" title="Permalink to this headline">¶</a></h3>
<p>Documentation and download information (if applicable) for OurSQL is available at:
<a class="reference external" href="http://packages.python.org/oursql/">http://packages.python.org/oursql/</a></p>
</div>
<div class="section" id="dialect-mysql-oursql-connect">
<h3>Connecting<a class="headerlink" href="#dialect-mysql-oursql-connect" title="Permalink to this headline">¶</a></h3>
<p>Connect String:<div class="highlight-python"><pre>mysql+oursql://<user>:<password>@<host>[:<port>]/<dbname></pre>
</div>
</p>
</div>
<div class="section" id="id2">
<h3>Unicode<a class="headerlink" href="#id2" 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.pymysql">
<span id="pymysql"></span><h2>pymysql<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.pymysql" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via the PyMySQL driver.</p>
<div class="section" id="dialect-mysql-pymysql-url">
<h3>DBAPI<a class="headerlink" href="#dialect-mysql-pymysql-url" title="Permalink to this headline">¶</a></h3>
<p>Documentation and download information (if applicable) for PyMySQL is available at:
<a class="reference external" href="http://code.google.com/p/pymysql/">http://code.google.com/p/pymysql/</a></p>
</div>
<div class="section" id="dialect-mysql-pymysql-connect">
<h3>Connecting<a class="headerlink" href="#dialect-mysql-pymysql-connect" title="Permalink to this headline">¶</a></h3>
<p>Connect String:<div class="highlight-python"><pre>mysql+pymysql://<username>:<password>@<host>/<dbname>[?<options>]</pre>
</div>
</p>
</div>
<div class="section" id="mysql-python-compatibility">
<h3>MySQL-Python Compatibility<a class="headerlink" href="#mysql-python-compatibility" title="Permalink to this headline">¶</a></h3>
<p>The pymysql DBAPI is a pure Python port of the MySQL-python (MySQLdb) driver,
and targets 100% compatibility. Most behavioral notes for MySQL-python apply
to the pymysql driver as well.</p>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.mysqlconnector">
<span id="mysql-connector"></span><h2>MySQL-Connector<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 driver.</p>
<div class="section" id="dialect-mysql-mysqlconnector-url">
<h3>DBAPI<a class="headerlink" href="#dialect-mysql-mysqlconnector-url" title="Permalink to this headline">¶</a></h3>
<p>Documentation and download information (if applicable) for MySQL Connector/Python is available at:
<a class="reference external" href="http://dev.mysql.com/downloads/connector/python/">http://dev.mysql.com/downloads/connector/python/</a></p>
</div>
<div class="section" id="dialect-mysql-mysqlconnector-connect">
<h3>Connecting<a class="headerlink" href="#dialect-mysql-mysqlconnector-connect" title="Permalink to this headline">¶</a></h3>
<p>Connect String:<div class="highlight-python"><pre>mysql+mysqlconnector://<user>:<password>@<host>[:<port>]/<dbname></pre>
</div>
</p>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.cymysql">
<span id="cymysql"></span><h2>cymysql<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.cymysql" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via the CyMySQL driver.</p>
<div class="section" id="dialect-mysql-cymysql-url">
<h3>DBAPI<a class="headerlink" href="#dialect-mysql-cymysql-url" title="Permalink to this headline">¶</a></h3>
<p>Documentation and download information (if applicable) for CyMySQL is available at:
<a class="reference external" href="https://github.com/nakagami/CyMySQL">https://github.com/nakagami/CyMySQL</a></p>
</div>
<div class="section" id="dialect-mysql-cymysql-connect">
<h3>Connecting<a class="headerlink" href="#dialect-mysql-cymysql-connect" title="Permalink to this headline">¶</a></h3>
<p>Connect String:<div class="highlight-python"><pre>mysql+cymysql://<username>:<password>@<host>/<dbname>[?<options>]</pre>
</div>
</p>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.gaerdbms">
<span id="google-app-engine"></span><h2>Google App Engine<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.gaerdbms" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via the Google Cloud SQL driver.<p>This dialect is based primarily on the <a class="reference internal" href="#module-sqlalchemy.dialects.mysql.mysqldb" title="sqlalchemy.dialects.mysql.mysqldb"><tt class="xref py py-mod docutils literal"><span class="pre">mysql.mysqldb</span></tt></a> dialect with
minimal changes.</p>
<div class="versionadded">
<p><span>New in version 0.7.8.</span></p>
</div>
</p>
<div class="section" id="dialect-mysql-gaerdbms-url">
<h3>DBAPI<a class="headerlink" href="#dialect-mysql-gaerdbms-url" title="Permalink to this headline">¶</a></h3>
<p>Documentation and download information (if applicable) for Google Cloud SQL is available at:
<a class="reference external" href="https://developers.google.com/appengine/docs/python/cloud-sql/developers-guide">https://developers.google.com/appengine/docs/python/cloud-sql/developers-guide</a></p>
</div>
<div class="section" id="dialect-mysql-gaerdbms-connect">
<h3>Connecting<a class="headerlink" href="#dialect-mysql-gaerdbms-connect" title="Permalink to this headline">¶</a></h3>
<p>Connect String:<div class="highlight-python"><pre>mysql+gaerdbms:///<dbname>?instance=<instancename></pre>
</div>
</p>
</div>
<div class="section" id="pooling">
<h3>Pooling<a class="headerlink" href="#pooling" title="Permalink to this headline">¶</a></h3>
<p>Google App Engine connections appear to be randomly recycled,
so the dialect does not pool connections. The <a class="reference internal" href="../core/pooling.html#sqlalchemy.pool.NullPool" title="sqlalchemy.pool.NullPool"><tt class="xref py py-class docutils literal"><span class="pre">NullPool</span></tt></a>
implementation is installed within the <a class="reference internal" href="../core/connections.html#sqlalchemy.engine.Engine" title="sqlalchemy.engine.Engine"><tt class="xref py py-class docutils literal"><span class="pre">Engine</span></tt></a> by
default.</p>
</div>
</div>
<div class="section" id="module-sqlalchemy.dialects.mysql.pyodbc">
<span id="pyodbc"></span><h2>pyodbc<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 driver.</p>
<div class="section" id="dialect-mysql-pyodbc-url">
<h3>DBAPI<a class="headerlink" href="#dialect-mysql-pyodbc-url" title="Permalink to this headline">¶</a></h3>
<p>Documentation and download information (if applicable) for PyODBC is available at:
<a class="reference external" href="http://pypi.python.org/pypi/pyodbc/">http://pypi.python.org/pypi/pyodbc/</a></p>
</div>
<div class="section" id="dialect-mysql-pyodbc-connect">
<h3>Connecting<a class="headerlink" href="#dialect-mysql-pyodbc-connect" title="Permalink to this headline">¶</a></h3>
<p>Connect String:<div class="highlight-python"><pre>mysql+pyodbc://<username>:<password>@<dsnname></pre>
</div>
</p>
</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"></span><h2>zxjdbc<a class="headerlink" href="#module-sqlalchemy.dialects.mysql.zxjdbc" title="Permalink to this headline">¶</a></h2>
<p>Support for the MySQL database via the zxjdbc for Jython driver.</p>
<div class="section" id="dialect-mysql-zxjdbc-url">
<h3>DBAPI<a class="headerlink" href="#dialect-mysql-zxjdbc-url" title="Permalink to this headline">¶</a></h3>
<p>Drivers for this database are available 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="dialect-mysql-zxjdbc-connect">
<h3>Connecting<a class="headerlink" href="#dialect-mysql-zxjdbc-connect" title="Permalink to this headline">¶</a></h3>
<p>Connect String:<div class="highlight-python"><pre>mysql+zxjdbc://<user>:<password>@<hostname>[:<port>]/<database></pre>
</div>
</p>
</div>
<div class="section" id="character-sets">
<h3>Character Sets<a class="headerlink" href="#character-sets" 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
overridden via a <tt class="docutils literal"><span class="pre">create_engine</span></tt> URL parameter.</p>
</div>
</div>
</div>
</div>
</div>
<div id="docs-bottom-navigation" class="docs-navigation-links">
Previous:
<a href="mssql.html" title="previous chapter">Microsoft SQL Server</a>
Next:
<a href="oracle.html" title="next chapter">Oracle</a>
<div id="docs-copyright">
© <a href="../copyright.html">Copyright</a> 2007-2014, the SQLAlchemy authors and contributors.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2b1.
</div>
</div>
</div>
</body>
</html>
|