File: sqlelement.html

package info (click to toggle)
sqlalchemy 0.9.8%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,952 kB
  • ctags: 24,534
  • sloc: python: 152,282; ansic: 1,346; makefile: 257; xml: 17
file content (3758 lines) | stat: -rw-r--r-- 403,670 bytes parent folder | download
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
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
<!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>
            
    
                Column Elements and Expressions
             &mdash;
    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="SQL Statements and Expressions API" href="expression_api.html" />
        <link rel="next" title="Selectables, Tables, FROM objects" href="selectable.html" />
        <link rel="prev" title="SQL Statements and Expressions API" href="expression_api.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="expression_api.html" title="SQL Statements and Expressions API">Up</a> |

                    <a href="expression_api.html" title="SQL Statements and Expressions API">Prev</a> |
                    <a href="selectable.html" title="Selectables, Tables, FROM objects">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="#">            
                Column Elements and Expressions
            
        </a></h3>
        <ul>
<li><a class="reference internal" href="#">Column Elements and Expressions</a></li>
</ul>




        </div>

    </div>

    

    <div id="docs-body" class="withsidebar" >
        
<div class="section" id="module-sqlalchemy.sql.expression">
<span id="column-elements-and-expressions"></span><h1>Column Elements and Expressions<a class="headerlink" href="#module-sqlalchemy.sql.expression" title="Permalink to this headline">¶</a></h1>
<p>The most fundamental part of the SQL expression API are the &#8220;column elements&#8221;,
which allow for basic SQL expression support.   The core of all SQL expression
constructs is the <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>, which is the base for several
sub-branches.  The <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> class is the fundamental unit
used to construct any kind of typed SQL expression.</p>
<dl class="function">
<dt id="sqlalchemy.sql.expression.and_">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">and_</tt><big>(</big><em>*clauses</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.and_" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a conjunction of expressions joined by <tt class="docutils literal"><span class="pre">AND</span></tt>.</p>
<p>E.g.:</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">and_</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span>
                <span class="n">and_</span><span class="p">(</span>
                    <span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">,</span>
                    <span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">enrolled</span> <span class="o">==</span> <span class="bp">True</span>
                <span class="p">)</span>
            <span class="p">)</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.and_" title="sqlalchemy.sql.expression.and_"><tt class="xref py py-func docutils literal"><span class="pre">and_()</span></tt></a> conjunction is also available using the
Python <tt class="docutils literal"><span class="pre">&amp;</span></tt> operator (though note that compound expressions
need to be parenthesized in order to function with Python
operator precedence behavior):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span>
                <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">)</span> <span class="o">&amp;</span>
                <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">enrolled</span> <span class="o">==</span> <span class="bp">True</span><span class="p">)</span>
            <span class="p">)</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.and_" title="sqlalchemy.sql.expression.and_"><tt class="xref py py-func docutils literal"><span class="pre">and_()</span></tt></a> operation is also implicit in some cases;
the <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.where" title="sqlalchemy.sql.expression.Select.where"><tt class="xref py py-meth docutils literal"><span class="pre">Select.where()</span></tt></a> method for example can be invoked multiple
times against a statement, which will have the effect of each
clause being combined using <a class="reference internal" href="#sqlalchemy.sql.expression.and_" title="sqlalchemy.sql.expression.and_"><tt class="xref py py-func docutils literal"><span class="pre">and_()</span></tt></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">where</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">)</span><span class="o">.</span>\
            <span class="n">where</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">enrolled</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="#sqlalchemy.sql.expression.or_" title="sqlalchemy.sql.expression.or_"><tt class="xref py py-func docutils literal"><span class="pre">or_()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.asc">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">asc</tt><big>(</big><em>column</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.asc" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce an ascending <tt class="docutils literal"><span class="pre">ORDER</span> <span class="pre">BY</span></tt> clause element.</p>
<p>e.g.:</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">asc</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="n">asc</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">))</span></pre></div>
</div>
<p>will produce SQL as:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user ORDER BY name ASC</pre>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a> function is a standalone version of the
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.asc" title="sqlalchemy.sql.expression.ColumnElement.asc"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.asc()</span></tt></a> method available on all SQL expressions,
e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">asc</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"><span class="target" id="sqlalchemy.sql.expression.asc.params.column"></span><strong>column</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.asc.params.column">¶</a> &#8211; A <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> (e.g. scalar SQL expression)
with which to apply the <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a> operation.</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.nullsfirst" title="sqlalchemy.sql.expression.nullsfirst"><tt class="xref py py-func docutils literal"><span class="pre">nullsfirst()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.nullslast" title="sqlalchemy.sql.expression.nullslast"><tt class="xref py py-func docutils literal"><span class="pre">nullslast()</span></tt></a></p>
<p class="last"><a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.order_by" title="sqlalchemy.sql.expression.Select.order_by"><tt class="xref py py-meth docutils literal"><span class="pre">Select.order_by()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.between">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">between</tt><big>(</big><em>expr</em>, <em>lower_bound</em>, <em>upper_bound</em>, <em>symmetric=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.between" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <tt class="docutils literal"><span class="pre">BETWEEN</span></tt> predicate clause.</p>
<p>E.g.:</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">between</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">between</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span></pre></div>
</div>
<p>Would produce SQL resembling:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user WHERE id BETWEEN :id_1 AND :id_2</pre>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.between" title="sqlalchemy.sql.expression.between"><tt class="xref py py-func docutils literal"><span class="pre">between()</span></tt></a> function is a standalone version of the
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.between" title="sqlalchemy.sql.expression.ColumnElement.between"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.between()</span></tt></a> method available on all
SQL expressions, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">id</span><span class="o">.</span><span class="n">between</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span></pre></div>
</div>
<p>All arguments passed to <a class="reference internal" href="#sqlalchemy.sql.expression.between" title="sqlalchemy.sql.expression.between"><tt class="xref py py-func docutils literal"><span class="pre">between()</span></tt></a>, including the left side
column expression, are coerced from Python scalar values if a
the value is not a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> subclass.   For example,
three fixed values can be compared as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">print</span><span class="p">(</span><span class="n">between</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span></pre></div>
</div>
<p>Which would produce:</p>
<div class="highlight-python"><pre>:param_1 BETWEEN :param_2 AND :param_3</pre>
</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.sql.expression.between.params.expr"></span><strong>expr</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.between.params.expr">¶</a> &#8211; a column expression, typically a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>
instance or alternatively a Python scalar expression to be coerced
into a column expression, serving as the left side of the <tt class="docutils literal"><span class="pre">BETWEEN</span></tt>
expression.</li>
<li><span class="target" id="sqlalchemy.sql.expression.between.params.lower_bound"></span><strong>lower_bound</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.between.params.lower_bound">¶</a> &#8211; a column or Python scalar expression serving as the
lower bound of the right side of the <tt class="docutils literal"><span class="pre">BETWEEN</span></tt> expression.</li>
<li><span class="target" id="sqlalchemy.sql.expression.between.params.upper_bound"></span><strong>upper_bound</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.between.params.upper_bound">¶</a> &#8211; a column or Python scalar expression serving as the
upper bound of the right side of the <tt class="docutils literal"><span class="pre">BETWEEN</span></tt> expression.</li>
<li><span class="target" id="sqlalchemy.sql.expression.between.params.symmetric"></span><strong>symmetric</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.between.params.symmetric">¶</a> &#8211; <p>if True, will render &#8221; BETWEEN SYMMETRIC &#8221;. Note
that not all databases support this syntax.</p>
<div class="versionadded">
<p><span>New in version 0.9.5.</span></p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.between" title="sqlalchemy.sql.expression.ColumnElement.between"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.between()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.bindparam">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">bindparam</tt><big>(</big><em>key</em>, <em>value=symbol('NO_ARG')</em>, <em>type_=None</em>, <em>unique=False</em>, <em>required=symbol('NO_ARG')</em>, <em>quote=None</em>, <em>callable_=None</em>, <em>isoutparam=False</em>, <em>_compared_to_operator=None</em>, <em>_compared_to_type=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.bindparam" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a &#8220;bound expression&#8221;.</p>
<p>The return value is an instance of <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a>; this
is a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> subclass which represents a so-called
&#8220;placeholder&#8221; value in a SQL expression, the value of which is
supplied at the point at which the statement in executed against a
database connection.</p>
<p>In SQLAlchemy, the <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> construct has
the ability to carry along the actual value that will be ultimately
used at expression time.  In this way, it serves not just as
a &#8220;placeholder&#8221; for eventual population, but also as a means of
representing so-called &#8220;unsafe&#8221; values which should not be rendered
directly in a SQL statement, but rather should be passed along
to the <a class="reference internal" href="../glossary.html#term-dbapi"><em class="xref std std-term">DBAPI</em></a> as values which need to be correctly escaped
and potentially handled for type-safety.</p>
<p>When using <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> explicitly, the use case is typically
one of traditional deferment of parameters; the <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a>
construct accepts a name which can then be referred to at execution
time:</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">bindparam</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">where</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;username&#39;</span><span class="p">))</span></pre></div>
</div>
<p>The above statement, when rendered, will produce SQL similar to:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user WHERE name = :username</pre>
</div>
<p>In order to populate the value of <tt class="docutils literal"><span class="pre">:username</span></tt> above, the value
would typically be applied at execution time to a method
like <a class="reference internal" href="connections.html#sqlalchemy.engine.Connection.execute" title="sqlalchemy.engine.Connection.execute"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.execute()</span></tt></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">result</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">stmt</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="s">&#39;wendy&#39;</span><span class="p">)</span></pre></div>
</div>
<p>Explicit use of <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> is also common when producing
UPDATE or DELETE statements that are to be invoked multiple times,
where the WHERE criterion of the statement is to change on each
invocation, such as:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">update</span><span class="p">()</span><span class="o">.</span>
        <span class="n">where</span><span class="p">(</span><span class="n">user_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;username&#39;</span><span class="p">))</span><span class="o">.</span>
        <span class="n">values</span><span class="p">(</span><span class="n">fullname</span><span class="o">=</span><span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;fullname&#39;</span><span class="p">))</span>
        <span class="p">)</span>

<span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span>
    <span class="n">stmt</span><span class="p">,</span> <span class="p">[{</span><span class="s">&quot;username&quot;</span><span class="p">:</span> <span class="s">&quot;wendy&quot;</span><span class="p">,</span> <span class="s">&quot;fullname&quot;</span><span class="p">:</span> <span class="s">&quot;Wendy Smith&quot;</span><span class="p">},</span>
           <span class="p">{</span><span class="s">&quot;username&quot;</span><span class="p">:</span> <span class="s">&quot;jack&quot;</span><span class="p">,</span> <span class="s">&quot;fullname&quot;</span><span class="p">:</span> <span class="s">&quot;Jack Jones&quot;</span><span class="p">},</span>
           <span class="p">]</span>
<span class="p">)</span></pre></div>
</div>
<p>SQLAlchemy&#8217;s Core expression system makes wide use of
<a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> in an implicit sense.   It is typical that Python
literal values passed to virtually all SQL expression functions are
coerced into fixed <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> constructs.  For example, given
a comparison operation such as:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">expr</span> <span class="o">=</span> <span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;Wendy&#39;</span></pre></div>
</div>
<p>The above expression will produce a <a class="reference internal" href="#sqlalchemy.sql.expression.BinaryExpression" title="sqlalchemy.sql.expression.BinaryExpression"><tt class="xref py py-class docutils literal"><span class="pre">BinaryExpression</span></tt></a>
construct, where the left side is the <a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> object
representing the <tt class="docutils literal"><span class="pre">name</span></tt> column, and the right side is a
<a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> representing the literal value:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">print</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">expr</span><span class="o">.</span><span class="n">right</span><span class="p">))</span>
<span class="n">BindParameter</span><span class="p">(</span><span class="s">&#39;%(4327771088 name)s&#39;</span><span class="p">,</span> <span class="s">&#39;Wendy&#39;</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">String</span><span class="p">())</span></pre></div>
</div>
<p>The expression above will render SQL such as:</p>
<div class="highlight-python"><pre>user.name = :name_1</pre>
</div>
<p>Where the <tt class="docutils literal"><span class="pre">:name_1</span></tt> parameter name is an anonymous name.  The
actual string <tt class="docutils literal"><span class="pre">Wendy</span></tt> is not in the rendered string, but is carried
along where it is later used within statement execution.  If we
invoke a statement like the following:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;Wendy&#39;</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">stmt</span><span class="p">)</span></pre></div>
</div>
<p>We would see SQL logging output as:</p>
<div class="highlight-python"><pre>SELECT "user".id, "user".name
FROM "user"
WHERE "user".name = %(name_1)s
{'name_1': 'Wendy'}</pre>
</div>
<p>Above, we see that <tt class="docutils literal"><span class="pre">Wendy</span></tt> is passed as a parameter to the database,
while the placeholder <tt class="docutils literal"><span class="pre">:name_1</span></tt> is rendered in the appropriate form
for the target database, in this case the Postgresql database.</p>
<p>Similarly, <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> is invoked automatically
when working with <a class="reference internal" href="../glossary.html#term-crud"><em class="xref std std-term">CRUD</em></a> statements as far as the &#8220;VALUES&#8221;
portion is concerned.   The <a class="reference internal" href="dml.html#sqlalchemy.sql.expression.insert" title="sqlalchemy.sql.expression.insert"><tt class="xref py py-func docutils literal"><span class="pre">insert()</span></tt></a> construct produces an
<tt class="docutils literal"><span class="pre">INSERT</span></tt> expression which will, at statement execution time,
generate bound placeholders based on the arguments passed, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">users_table</span><span class="o">.</span><span class="n">insert</span><span class="p">()</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">stmt</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">&#39;Wendy&#39;</span><span class="p">)</span></pre></div>
</div>
<p>The above will produce SQL output as:</p>
<div class="highlight-python"><pre>INSERT INTO "user" (name) VALUES (%(name)s)
{'name': 'Wendy'}</pre>
</div>
<p>The <a class="reference internal" href="dml.html#sqlalchemy.sql.expression.Insert" title="sqlalchemy.sql.expression.Insert"><tt class="xref py py-class docutils literal"><span class="pre">Insert</span></tt></a> construct, at compilation/execution time,
rendered a single <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> mirroring the column
name <tt class="docutils literal"><span class="pre">name</span></tt> as a result of the single <tt class="docutils literal"><span class="pre">name</span></tt> parameter
we passed to the <a class="reference internal" href="connections.html#sqlalchemy.engine.Connection.execute" title="sqlalchemy.engine.Connection.execute"><tt class="xref py py-meth docutils literal"><span class="pre">Connection.execute()</span></tt></a> method.</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.sql.expression.bindparam.params.key"></span><strong>key</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.bindparam.params.key">¶</a> &#8211; the key (e.g. the name) for this bind param.
Will be used in the generated
SQL statement for dialects that use named parameters.  This
value may be modified when part of a compilation operation,
if other <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> objects exist with the same
key, or if its length is too long and truncation is
required.</li>
<li><span class="target" id="sqlalchemy.sql.expression.bindparam.params.value"></span><strong>value</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.bindparam.params.value">¶</a> &#8211; Initial value for this bind param.  Will be used at statement
execution time as the value for this parameter passed to the
DBAPI, if no other value is indicated to the statement execution
method for this particular parameter name.  Defaults to <tt class="docutils literal"><span class="pre">None</span></tt>.</li>
<li><span class="target" id="sqlalchemy.sql.expression.bindparam.params.callable_"></span><strong>callable_</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.bindparam.params.callable_">¶</a> &#8211; A callable function that takes the place of &#8220;value&#8221;.  The function
will be called at statement execution time to determine the
ultimate value.   Used for scenarios where the actual bind
value cannot be determined at the point at which the clause
construct is created, but embedded bind values are still desirable.</li>
<li><span class="target" id="sqlalchemy.sql.expression.bindparam.params.type_"></span><strong>type_</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.bindparam.params.type_">¶</a> &#8211; <p>A <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">TypeEngine</span></tt></a> class or instance representing an optional
datatype for this <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a>.  If not passed, a type
may be determined automatically for the bind, based on the given
value; for example, trivial Python types such as <tt class="docutils literal"><span class="pre">str</span></tt>,
<tt class="docutils literal"><span class="pre">int</span></tt>, <tt class="docutils literal"><span class="pre">bool</span></tt>
may result in the <a class="reference internal" href="types.html#sqlalchemy.types.String" title="sqlalchemy.types.String"><tt class="xref py py-class docutils literal"><span class="pre">String</span></tt></a>, <a class="reference internal" href="types.html#sqlalchemy.types.Integer" title="sqlalchemy.types.Integer"><tt class="xref py py-class docutils literal"><span class="pre">Integer</span></tt></a> or
<a class="reference internal" href="types.html#sqlalchemy.types.Boolean" title="sqlalchemy.types.Boolean"><tt class="xref py py-class docutils literal"><span class="pre">Boolean</span></tt></a> types being autoamtically selected.</p>
<p>The type of a <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> is significant especially in that
the type will apply pre-processing to the value before it is
passed to the database.  For example, a <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> which
refers to a datetime value, and is specified as holding the
<a class="reference internal" href="types.html#sqlalchemy.types.DateTime" title="sqlalchemy.types.DateTime"><tt class="xref py py-class docutils literal"><span class="pre">DateTime</span></tt></a> type, may apply conversion needed to the
value (such as stringification on SQLite) before passing the value
to the database.</p>
</li>
<li><span class="target" id="sqlalchemy.sql.expression.bindparam.params.unique"></span><strong>unique</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.bindparam.params.unique">¶</a> &#8211; if True, the key name of this <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> will be
modified if another <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> of the same name
already has been located within the containing
expression.  This flag is used generally by the internals
when producing so-called &#8220;anonymous&#8221; bound expressions, it
isn&#8217;t generally applicable to explicitly-named <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a>
constructs.</li>
<li><span class="target" id="sqlalchemy.sql.expression.bindparam.params.required"></span><strong>required</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.bindparam.params.required">¶</a> &#8211; <p>If <tt class="docutils literal"><span class="pre">True</span></tt>, a value is required at execution time.  If not passed,
it defaults to <tt class="docutils literal"><span class="pre">True</span></tt> if neither <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam.params.value" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-paramref docutils literal"><span class="pre">bindparam.value</span></tt></a>
or <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam.params.callable" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-paramref docutils literal"><span class="pre">bindparam.callable</span></tt></a> were passed.  If either of these
parameters are present, then <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam.params.required" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-paramref docutils literal"><span class="pre">bindparam.required</span></tt></a>
defaults to <tt class="docutils literal"><span class="pre">False</span></tt>.</p>
<div class="versionchanged">
<p><span>Changed in version 0.8: </span>If the <tt class="docutils literal"><span class="pre">required</span></tt> flag is not specified,
it will be set automatically to <tt class="docutils literal"><span class="pre">True</span></tt> or <tt class="docutils literal"><span class="pre">False</span></tt> depending
on whether or not the <tt class="docutils literal"><span class="pre">value</span></tt> or <tt class="docutils literal"><span class="pre">callable</span></tt> parameters
were specified.</p>
</div>
</li>
<li><span class="target" id="sqlalchemy.sql.expression.bindparam.params.quote"></span><strong>quote</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.bindparam.params.quote">¶</a> &#8211; True if this parameter name requires quoting and is not
currently known as a SQLAlchemy reserved word; this currently
only applies to the Oracle backend, where bound names must
sometimes be quoted.</li>
<li><span class="target" id="sqlalchemy.sql.expression.bindparam.params.isoutparam"></span><strong>isoutparam</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.bindparam.params.isoutparam">¶</a> &#8211; if True, the parameter should be treated like a stored procedure
&#8220;OUT&#8221; parameter.  This applies to backends such as Oracle which
support OUT parameters.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="tutorial.html#coretutorial-bind-param"><em>Bind Parameter Objects</em></a></p>
<p><a class="reference internal" href="tutorial.html#coretutorial-insert-expressions"><em>Insert Expressions</em></a></p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.outparam" title="sqlalchemy.sql.expression.outparam"><tt class="xref py py-func docutils literal"><span class="pre">outparam()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.case">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">case</tt><big>(</big><em>whens</em>, <em>value=None</em>, <em>else_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.case" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <tt class="docutils literal"><span class="pre">CASE</span></tt> expression.</p>
<p>The <tt class="docutils literal"><span class="pre">CASE</span></tt> construct in SQL is a conditional object that
acts somewhat analogously to an &#8220;if/then&#8221; construct in other
languages.  It returns an instance of <a class="reference internal" href="#sqlalchemy.sql.expression.Case" title="sqlalchemy.sql.expression.Case"><tt class="xref py py-class docutils literal"><span class="pre">Case</span></tt></a>.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.case" title="sqlalchemy.sql.expression.case"><tt class="xref py py-func docutils literal"><span class="pre">case()</span></tt></a> in its usual form is passed a list of &#8220;when&#8221;
constructs, that is, a list of conditions and results as tuples:</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">case</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">where</span><span class="p">(</span>
                <span class="n">case</span><span class="p">(</span>
                    <span class="p">[</span>
                        <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">,</span> <span class="s">&#39;W&#39;</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;jack&#39;</span><span class="p">,</span> <span class="s">&#39;J&#39;</span><span class="p">)</span>
                    <span class="p">],</span>
                    <span class="n">else_</span><span class="o">=</span><span class="s">&#39;E&#39;</span>
                <span class="p">)</span>
            <span class="p">)</span></pre></div>
</div>
<p>The above statement will produce SQL resembling:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user
WHERE CASE
    WHEN (name = :name_1) THEN :param_1
    WHEN (name = :name_2) THEN :param_2
    ELSE :param_3
END</pre>
</div>
<p>When simple equality expressions of several values against a single
parent column are needed, <a class="reference internal" href="#sqlalchemy.sql.expression.case" title="sqlalchemy.sql.expression.case"><tt class="xref py py-func docutils literal"><span class="pre">case()</span></tt></a> also has a &#8220;shorthand&#8221; format
used via the
<a class="reference internal" href="#sqlalchemy.sql.expression.case.params.value" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.value</span></tt></a> parameter, which is passed a column
expression to be compared.  In this form, the <a class="reference internal" href="#sqlalchemy.sql.expression.case.params.whens" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.whens</span></tt></a>
parameter is passed as a dictionary containing expressions to be
compared against keyed to result expressions.  The statement below is
equivalent to the preceding statement:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">where</span><span class="p">(</span>
                <span class="n">case</span><span class="p">(</span>
                    <span class="p">{</span><span class="s">&quot;wendy&quot;</span><span class="p">:</span> <span class="s">&quot;W&quot;</span><span class="p">,</span> <span class="s">&quot;jack&quot;</span><span class="p">:</span> <span class="s">&quot;J&quot;</span><span class="p">},</span>
                    <span class="n">value</span><span class="o">=</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
                    <span class="n">else_</span><span class="o">=</span><span class="s">&#39;E&#39;</span>
                <span class="p">)</span>
            <span class="p">)</span></pre></div>
</div>
<p>The values which are accepted as result values in
<a class="reference internal" href="#sqlalchemy.sql.expression.case.params.whens" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.whens</span></tt></a> as well as with <a class="reference internal" href="#sqlalchemy.sql.expression.case.params.else_" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.else_</span></tt></a> are
coerced from Python literals into <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> constructs.
SQL expressions, e.g. <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> constructs, are accepted
as well.  To coerce a literal string expression into a constant
expression rendered inline, use the <a class="reference internal" href="#sqlalchemy.sql.expression.literal_column" title="sqlalchemy.sql.expression.literal_column"><tt class="xref py py-func docutils literal"><span class="pre">literal_column()</span></tt></a> construct,
as in:</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">case</span><span class="p">,</span> <span class="n">literal_column</span>

<span class="n">case</span><span class="p">(</span>
    <span class="p">[</span>
        <span class="p">(</span>
            <span class="n">orderline</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">qty</span> <span class="o">&gt;</span> <span class="mi">100</span><span class="p">,</span>
            <span class="n">literal_column</span><span class="p">(</span><span class="s">&quot;&#39;greaterthan100&#39;&quot;</span><span class="p">)</span>
        <span class="p">),</span>
        <span class="p">(</span>
            <span class="n">orderline</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">qty</span> <span class="o">&gt;</span> <span class="mi">10</span><span class="p">,</span>
            <span class="n">literal_column</span><span class="p">(</span><span class="s">&quot;&#39;greaterthan10&#39;&quot;</span><span class="p">)</span>
        <span class="p">)</span>
    <span class="p">],</span>
    <span class="n">else_</span><span class="o">=</span><span class="n">literal_column</span><span class="p">(</span><span class="s">&quot;&#39;lessthan10&#39;&quot;</span><span class="p">)</span>
<span class="p">)</span></pre></div>
</div>
<p>The above will render the given constants without using bound
parameters for the result values (but still for the comparison
values), as in:</p>
<div class="highlight-python"><pre>CASE
    WHEN (orderline.qty &gt; :qty_1) THEN 'greaterthan100'
    WHEN (orderline.qty &gt; :qty_2) THEN 'greaterthan10'
    ELSE 'lessthan10'
END</pre>
</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.sql.expression.case.params.whens"></span><strong>whens</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.case.params.whens">¶</a> &#8211; <p>The criteria to be compared against,
<a class="reference internal" href="#sqlalchemy.sql.expression.case.params.whens" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.whens</span></tt></a> accepts two different forms, based on
whether or not <a class="reference internal" href="#sqlalchemy.sql.expression.case.params.value" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.value</span></tt></a> is used.</p>
<p>In the first form, it accepts a list of 2-tuples; each 2-tuple
consists of <tt class="docutils literal"><span class="pre">(&lt;sql</span> <span class="pre">expression&gt;,</span> <span class="pre">&lt;value&gt;)</span></tt>, where the SQL
expression is a boolean expression and &#8220;value&#8221; is a resulting value,
e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">case</span><span class="p">([</span>
    <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">,</span> <span class="s">&#39;W&#39;</span><span class="p">),</span>
    <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;jack&#39;</span><span class="p">,</span> <span class="s">&#39;J&#39;</span><span class="p">)</span>
<span class="p">])</span></pre></div>
</div>
<p>In the second form, it accepts a Python dictionary of comparison
values mapped to a resulting value; this form requires
<a class="reference internal" href="#sqlalchemy.sql.expression.case.params.value" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.value</span></tt></a> to be present, and values will be compared
using the <tt class="docutils literal"><span class="pre">==</span></tt> operator, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">case</span><span class="p">(</span>
    <span class="p">{</span><span class="s">&quot;wendy&quot;</span><span class="p">:</span> <span class="s">&quot;W&quot;</span><span class="p">,</span> <span class="s">&quot;jack&quot;</span><span class="p">:</span> <span class="s">&quot;J&quot;</span><span class="p">},</span>
    <span class="n">value</span><span class="o">=</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span>
<span class="p">)</span></pre></div>
</div>
</li>
<li><span class="target" id="sqlalchemy.sql.expression.case.params.value"></span><strong>value</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.case.params.value">¶</a> &#8211; An optional SQL expression which will be used as a
fixed &#8220;comparison point&#8221; for candidate values within a dictionary
passed to <a class="reference internal" href="#sqlalchemy.sql.expression.case.params.whens" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.whens</span></tt></a>.</li>
<li><span class="target" id="sqlalchemy.sql.expression.case.params.else_"></span><strong>else_</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.case.params.else_">¶</a> &#8211; An optional SQL expression which will be the evaluated
result of the <tt class="docutils literal"><span class="pre">CASE</span></tt> construct if all expressions within
<a class="reference internal" href="#sqlalchemy.sql.expression.case.params.whens" title="sqlalchemy.sql.expression.case"><tt class="xref py py-paramref docutils literal"><span class="pre">case.whens</span></tt></a> evaluate to false.  When omitted, most
databases will produce a result of NULL if none of the &#8220;when&#8221;
expressions evaulate to true.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.cast">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">cast</tt><big>(</big><em>expression</em>, <em>type_</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.cast" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <tt class="docutils literal"><span class="pre">CAST</span></tt> expression.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a> returns an instance of <a class="reference internal" href="#sqlalchemy.sql.expression.Cast" title="sqlalchemy.sql.expression.Cast"><tt class="xref py py-class docutils literal"><span class="pre">Cast</span></tt></a>.</p>
<p>E.g.:</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">cast</span><span class="p">,</span> <span class="n">Numeric</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span>
            <span class="n">cast</span><span class="p">(</span><span class="n">product_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">unit_price</span><span class="p">,</span> <span class="n">Numeric</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
        <span class="p">])</span></pre></div>
</div>
<p>The above statement will produce SQL resembling:</p>
<div class="highlight-python"><pre>SELECT CAST(unit_price AS NUMERIC(10, 4)) FROM product</pre>
</div>
<p>The <a class="reference internal" href="#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 performs two distinct functions when
used.  The first is that it renders the <tt class="docutils literal"><span class="pre">CAST</span></tt> expression within
the resulting SQL string.  The second is that it associates the given
type (e.g. <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">TypeEngine</span></tt></a> class or instance) with the column
expression on the Python side, which means the expression will take
on the expression operator behavior associated with that type,
as well as the bound-value handling and result-row-handling behavior
of the type.</p>
<div class="versionchanged">
<p><span>Changed in version 0.9.0: </span><a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a> now applies the given type
to the expression such that it takes effect on the bound-value,
e.g. the Python-to-database direction, in addition to the
result handling, e.g. database-to-Python, direction.</p>
</div>
<p>An alternative to <a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a> is the <a class="reference internal" href="#sqlalchemy.sql.expression.type_coerce" title="sqlalchemy.sql.expression.type_coerce"><tt class="xref py py-func docutils literal"><span class="pre">type_coerce()</span></tt></a> function.
This function performs the second task of associating an expression
with a specific type, but does not render the <tt class="docutils literal"><span class="pre">CAST</span></tt> expression
in SQL.</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.sql.expression.cast.params.expression"></span><strong>expression</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.cast.params.expression">¶</a> &#8211; A SQL expression, such as a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>
expression or a Python string which will be coerced into a bound
literal value.</li>
<li><span class="target" id="sqlalchemy.sql.expression.cast.params.type_"></span><strong>type_</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.cast.params.type_">¶</a> &#8211; A <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">TypeEngine</span></tt></a> class or instance indicating
the type to which the <tt class="docutils literal"><span class="pre">CAST</span></tt> should apply.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.type_coerce" title="sqlalchemy.sql.expression.type_coerce"><tt class="xref py py-func docutils literal"><span class="pre">type_coerce()</span></tt></a> - Python-side type coercion without emitting
CAST.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.column">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">column</tt><big>(</big><em>text</em>, <em>type_=None</em>, <em>is_literal=False</em>, <em>_selectable=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.column" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> object.</p>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> is a lightweight analogue to the
<a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> class.  The <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> function can
be invoked with just a name alone, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">column</span>

<span class="nb">id</span><span class="p">,</span> <span class="n">name</span> <span class="o">=</span> <span class="n">column</span><span class="p">(</span><span class="s">&quot;id&quot;</span><span class="p">),</span> <span class="n">column</span><span class="p">(</span><span class="s">&quot;name&quot;</span><span class="p">)</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">])</span><span class="o">.</span><span class="n">select_from</span><span class="p">(</span><span class="s">&quot;user&quot;</span><span class="p">)</span></pre></div>
</div>
<p>The above statement would produce SQL like:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user</pre>
</div>
<p>Once constructed, <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> may be used like any other SQL
expression element such as within <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.select" title="sqlalchemy.sql.expression.select"><tt class="xref py py-func docutils literal"><span class="pre">select()</span></tt></a> constructs:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">column</span>

<span class="nb">id</span><span class="p">,</span> <span class="n">name</span> <span class="o">=</span> <span class="n">column</span><span class="p">(</span><span class="s">&quot;id&quot;</span><span class="p">),</span> <span class="n">column</span><span class="p">(</span><span class="s">&quot;name&quot;</span><span class="p">)</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">])</span><span class="o">.</span><span class="n">select_from</span><span class="p">(</span><span class="s">&quot;user&quot;</span><span class="p">)</span></pre></div>
</div>
<p>The text handled by <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> is assumed to be handled
like the name of a database column; if the string contains mixed case,
special characters, or matches a known reserved word on the target
backend, the column expression will render using the quoting
behavior determined by the backend.  To produce a textual SQL
expression that is rendered exactly without any quoting,
use <a class="reference internal" href="#sqlalchemy.sql.expression.literal_column" title="sqlalchemy.sql.expression.literal_column"><tt class="xref py py-func docutils literal"><span class="pre">literal_column()</span></tt></a> instead, or pass <tt class="docutils literal"><span class="pre">True</span></tt> as the
value of <a class="reference internal" href="#sqlalchemy.sql.expression.column.params.is_literal" title="sqlalchemy.sql.expression.column"><tt class="xref py py-paramref docutils literal"><span class="pre">column.is_literal</span></tt></a>.   Additionally, full SQL
statements are best handled using the <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a> construct.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> can be used in a table-like
fashion by combining it with the <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.table" title="sqlalchemy.sql.expression.table"><tt class="xref py py-func docutils literal"><span class="pre">table()</span></tt></a> function
(which is the lightweight analogue to <a class="reference internal" href="metadata.html#sqlalchemy.schema.Table" title="sqlalchemy.schema.Table"><tt class="xref py py-class docutils literal"><span class="pre">Table</span></tt></a>) to produce
a working table construct with minimal boilerplate:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">table</span><span class="p">,</span> <span class="n">column</span>

<span class="n">user</span> <span class="o">=</span> <span class="n">table</span><span class="p">(</span><span class="s">&quot;user&quot;</span><span class="p">,</span>
        <span class="n">column</span><span class="p">(</span><span class="s">&quot;id&quot;</span><span class="p">),</span>
        <span class="n">column</span><span class="p">(</span><span class="s">&quot;name&quot;</span><span class="p">),</span>
        <span class="n">column</span><span class="p">(</span><span class="s">&quot;description&quot;</span><span class="p">),</span>
<span class="p">)</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">user</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">description</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">user</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">)</span></pre></div>
</div>
<p>A <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> / <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.table" title="sqlalchemy.sql.expression.table"><tt class="xref py py-func docutils literal"><span class="pre">table()</span></tt></a> construct like that illustrated
above can be created in an
ad-hoc fashion and is not associated with any
<a class="reference internal" href="metadata.html#sqlalchemy.schema.MetaData" title="sqlalchemy.schema.MetaData"><tt class="xref py py-class docutils literal"><span class="pre">schema.MetaData</span></tt></a>, DDL, or events, unlike its
<a class="reference internal" href="metadata.html#sqlalchemy.schema.Table" title="sqlalchemy.schema.Table"><tt class="xref py py-class docutils literal"><span class="pre">Table</span></tt></a> counterpart.</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.sql.expression.column.params.text"></span><strong>text</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.column.params.text">¶</a> &#8211; the text of the element.</li>
<li><span class="target" id="sqlalchemy.sql.expression.column.params.type"></span><strong>type</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.column.params.type">¶</a> &#8211; <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">types.TypeEngine</span></tt></a> object which can associate
this <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> with a type.</li>
<li><span class="target" id="sqlalchemy.sql.expression.column.params.is_literal"></span><strong>is_literal</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.column.params.is_literal">¶</a> &#8211; if True, the <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> is assumed to
be an exact expression that will be delivered to the output with no
quoting rules applied regardless of case sensitive settings. the
<a class="reference internal" href="#sqlalchemy.sql.expression.literal_column" title="sqlalchemy.sql.expression.literal_column"><tt class="xref py py-func docutils literal"><span class="pre">literal_column()</span></tt></a> function essentially invokes
<a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> while passing <tt class="docutils literal"><span class="pre">is_literal=True</span></tt>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.literal_column" title="sqlalchemy.sql.expression.literal_column"><tt class="xref py py-func docutils literal"><span class="pre">literal_column()</span></tt></a></p>
<p><a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.table" title="sqlalchemy.sql.expression.table"><tt class="xref py py-func docutils literal"><span class="pre">table()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a></p>
<p class="last"><a class="reference internal" href="tutorial.html#sqlexpression-literal-column"><em>Using More Specific Text with table(), literal_column(), and column()</em></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.collate">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">collate</tt><big>(</big><em>expression</em>, <em>collation</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.collate" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the clause <tt class="docutils literal"><span class="pre">expression</span> <span class="pre">COLLATE</span> <span class="pre">collation</span></tt>.</p>
<p>e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">collate</span><span class="p">(</span><span class="n">mycolumn</span><span class="p">,</span> <span class="s">&#39;utf8_bin&#39;</span><span class="p">)</span></pre></div>
</div>
<p>produces:</p>
<div class="highlight-python"><pre>mycolumn COLLATE utf8_bin</pre>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.desc">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">desc</tt><big>(</big><em>column</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.desc" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a descending <tt class="docutils literal"><span class="pre">ORDER</span> <span class="pre">BY</span></tt> clause element.</p>
<p>e.g.:</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">desc</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="n">desc</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">))</span></pre></div>
</div>
<p>will produce SQL as:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user ORDER BY name DESC</pre>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a> function is a standalone version of the
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.desc" title="sqlalchemy.sql.expression.ColumnElement.desc"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.desc()</span></tt></a> method available on all SQL expressions,
e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">desc</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"><span class="target" id="sqlalchemy.sql.expression.desc.params.column"></span><strong>column</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.desc.params.column">¶</a> &#8211; A <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> (e.g. scalar SQL expression)
with which to apply the <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a> operation.</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.nullsfirst" title="sqlalchemy.sql.expression.nullsfirst"><tt class="xref py py-func docutils literal"><span class="pre">nullsfirst()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.nullslast" title="sqlalchemy.sql.expression.nullslast"><tt class="xref py py-func docutils literal"><span class="pre">nullslast()</span></tt></a></p>
<p class="last"><a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.order_by" title="sqlalchemy.sql.expression.Select.order_by"><tt class="xref py py-meth docutils literal"><span class="pre">Select.order_by()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.distinct">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">distinct</tt><big>(</big><em>expr</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.distinct" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce an column-expression-level unary <tt class="docutils literal"><span class="pre">DISTINCT</span></tt> clause.</p>
<p>This applies the <tt class="docutils literal"><span class="pre">DISTINCT</span></tt> keyword to an individual column
expression, and is typically contained within an aggregate function,
as in:</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">distinct</span><span class="p">,</span> <span class="n">func</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">func</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="n">distinct</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">))])</span></pre></div>
</div>
<p>The above would produce an expression resembling:</p>
<div class="highlight-python"><pre>SELECT COUNT(DISTINCT name) FROM user</pre>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.distinct" title="sqlalchemy.sql.expression.distinct"><tt class="xref py py-func docutils literal"><span class="pre">distinct()</span></tt></a> function is also available as a column-level
method, e.g. <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.distinct" title="sqlalchemy.sql.expression.ColumnElement.distinct"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.distinct()</span></tt></a>, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">func</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">distinct</span><span class="p">())])</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.distinct" title="sqlalchemy.sql.expression.distinct"><tt class="xref py py-func docutils literal"><span class="pre">distinct()</span></tt></a> operator is different from the
<a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.distinct" title="sqlalchemy.sql.expression.Select.distinct"><tt class="xref py py-meth docutils literal"><span class="pre">Select.distinct()</span></tt></a> method of <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select" title="sqlalchemy.sql.expression.Select"><tt class="xref py py-class docutils literal"><span class="pre">Select</span></tt></a>,
which produces a <tt class="docutils literal"><span class="pre">SELECT</span></tt> statement
with <tt class="docutils literal"><span class="pre">DISTINCT</span></tt> applied to the result set as a whole,
e.g. a <tt class="docutils literal"><span class="pre">SELECT</span> <span class="pre">DISTINCT</span></tt> expression.  See that method for further
information.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.distinct" title="sqlalchemy.sql.expression.ColumnElement.distinct"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.distinct()</span></tt></a></p>
<p><a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.distinct" title="sqlalchemy.sql.expression.Select.distinct"><tt class="xref py py-meth docutils literal"><span class="pre">Select.distinct()</span></tt></a></p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.extract">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">extract</tt><big>(</big><em>field</em>, <em>expr</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.extract" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <a class="reference internal" href="#sqlalchemy.sql.expression.Extract" title="sqlalchemy.sql.expression.Extract"><tt class="xref py py-class docutils literal"><span class="pre">Extract</span></tt></a> construct.</p>
<p>This is typically available as <a class="reference internal" href="#sqlalchemy.sql.expression.extract" title="sqlalchemy.sql.expression.extract"><tt class="xref py py-func docutils literal"><span class="pre">extract()</span></tt></a>
as well as <tt class="docutils literal"><span class="pre">func.extract</span></tt> from the
<a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a> namespace.</p>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.false">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">false</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.false" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a constant <a class="reference internal" href="#sqlalchemy.sql.elements.False_" title="sqlalchemy.sql.elements.False_"><tt class="xref py py-class docutils literal"><span class="pre">False_</span></tt></a> construct.</p>
<p>E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sqlalchemy</span> <span class="kn">import</span> <span class="n">false</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">false</span><span class="p">())</span>
<span class="go">SELECT x FROM t WHERE false</span></pre></div>
</div>
<p>A backend which does not support true/false constants will render as
an expression against 1 or 0:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">false</span><span class="p">())</span>
<span class="go">SELECT x FROM t WHERE 0 = 1</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.true" title="sqlalchemy.sql.expression.true"><tt class="xref py py-func docutils literal"><span class="pre">true()</span></tt></a> and <a class="reference internal" href="#sqlalchemy.sql.expression.false" title="sqlalchemy.sql.expression.false"><tt class="xref py py-func docutils literal"><span class="pre">false()</span></tt></a> constants also feature
&#8220;short circuit&#8221; operation within an <a class="reference internal" href="#sqlalchemy.sql.expression.and_" title="sqlalchemy.sql.expression.and_"><tt class="xref py py-func docutils literal"><span class="pre">and_()</span></tt></a> or <a class="reference internal" href="#sqlalchemy.sql.expression.or_" title="sqlalchemy.sql.expression.or_"><tt class="xref py py-func docutils literal"><span class="pre">or_()</span></tt></a>
conjunction:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">or_</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span> <span class="o">&gt;</span> <span class="mi">5</span><span class="p">,</span> <span class="n">true</span><span class="p">()))</span>
<span class="go">SELECT x FROM t WHERE true</span>

<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">and_</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span> <span class="o">&gt;</span> <span class="mi">5</span><span class="p">,</span> <span class="n">false</span><span class="p">()))</span>
<span class="go">SELECT x FROM t WHERE false</span></pre></div>
</div>
<div class="versionchanged">
<p><span>Changed in version 0.9: </span><a class="reference internal" href="#sqlalchemy.sql.expression.true" title="sqlalchemy.sql.expression.true"><tt class="xref py py-func docutils literal"><span class="pre">true()</span></tt></a> and <a class="reference internal" href="#sqlalchemy.sql.expression.false" title="sqlalchemy.sql.expression.false"><tt class="xref py py-func docutils literal"><span class="pre">false()</span></tt></a> feature
better integrated behavior within conjunctions and on dialects
that don&#8217;t support true/false constants.</p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.true" title="sqlalchemy.sql.expression.true"><tt class="xref py py-func docutils literal"><span class="pre">true()</span></tt></a></p>
</div>
</dd></dl>

<dl class="data">
<dt id="sqlalchemy.sql.expression.func">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">func</tt><em class="property"> = &lt;sqlalchemy.sql.functions._FunctionGenerator object at 0x10371c4d0&gt;</em><a class="headerlink" href="#sqlalchemy.sql.expression.func" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate SQL function expressions.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a> is a special object instance which generates SQL
functions based on name-based attributes, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">func</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="go">count(:param_1)</span></pre></div>
</div>
<p>The element is a column-oriented SQL element like any other, and is
used in that way:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">func</span><span class="o">.</span><span class="n">count</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">id</span><span class="p">)])</span>
<span class="go">SELECT count(sometable.id) FROM sometable</span></pre></div>
</div>
<p>Any name can be given to <a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a>. If the function name is unknown to
SQLAlchemy, it will be rendered exactly as is. For common SQL functions
which SQLAlchemy is aware of, the name may be interpreted as a <em>generic
function</em> which will be compiled appropriately to the target database:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">func</span><span class="o">.</span><span class="n">current_timestamp</span><span class="p">()</span>
<span class="go">CURRENT_TIMESTAMP</span></pre></div>
</div>
<p>To call functions which are present in dot-separated packages,
specify them in the same manner:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">func</span><span class="o">.</span><span class="n">stats</span><span class="o">.</span><span class="n">yield_curve</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="go">stats.yield_curve(:yield_curve_1, :yield_curve_2)</span></pre></div>
</div>
<p>SQLAlchemy can be made aware of the return type of functions to enable
type-specific lexical and result-based behavior. For example, to ensure
that a string-based function returns a Unicode value and is similarly
treated as a string in expressions, specify
<a class="reference internal" href="types.html#sqlalchemy.types.Unicode" title="sqlalchemy.types.Unicode"><tt class="xref py py-class docutils literal"><span class="pre">Unicode</span></tt></a> as the type:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">func</span><span class="o">.</span><span class="n">my_string</span><span class="p">(</span><span class="s">u&#39;hi&#39;</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">Unicode</span><span class="p">)</span> <span class="o">+</span> <span class="s">&#39; &#39;</span> <span class="o">+</span> \
<span class="gp">... </span><span class="n">func</span><span class="o">.</span><span class="n">my_string</span><span class="p">(</span><span class="s">u&#39;there&#39;</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">Unicode</span><span class="p">)</span>
<span class="go">my_string(:my_string_1) || :my_string_2 || my_string(:my_string_3)</span></pre></div>
</div>
<p>The object returned by a <a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a> call is usually an instance of
<a class="reference internal" href="functions.html#sqlalchemy.sql.functions.Function" title="sqlalchemy.sql.functions.Function"><tt class="xref py py-class docutils literal"><span class="pre">Function</span></tt></a>.
This object meets the &#8220;column&#8221; interface, including comparison and labeling
functions.  The object can also be passed the <a class="reference internal" href="connections.html#sqlalchemy.engine.Connectable.execute" title="sqlalchemy.engine.Connectable.execute"><tt class="xref py py-meth docutils literal"><span class="pre">execute()</span></tt></a>
method of a <a class="reference internal" href="connections.html#sqlalchemy.engine.Connection" title="sqlalchemy.engine.Connection"><tt class="xref py py-class docutils literal"><span class="pre">Connection</span></tt></a> or <a class="reference internal" href="connections.html#sqlalchemy.engine.Engine" title="sqlalchemy.engine.Engine"><tt class="xref py py-class docutils literal"><span class="pre">Engine</span></tt></a>, where it will be
wrapped inside of a SELECT statement first:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">print</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">func</span><span class="o">.</span><span class="n">current_timestamp</span><span class="p">())</span><span class="o">.</span><span class="n">scalar</span><span class="p">()</span></pre></div>
</div>
<p>In a few exception cases, the <a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a> accessor
will redirect a name to a built-in expression such as <a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a>
or <a class="reference internal" href="#sqlalchemy.sql.expression.extract" title="sqlalchemy.sql.expression.extract"><tt class="xref py py-func docutils literal"><span class="pre">extract()</span></tt></a>, as these names have well-known meaning
but are not exactly the same as &#8220;functions&#8221; from a SQLAlchemy
perspective.</p>
<div class="versionadded">
<p><span>New in version 0.8: </span><a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a> can return non-function expression
constructs for common quasi-functional names like <a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a>
and <a class="reference internal" href="#sqlalchemy.sql.expression.extract" title="sqlalchemy.sql.expression.extract"><tt class="xref py py-func docutils literal"><span class="pre">extract()</span></tt></a>.</p>
</div>
<p>Functions which are interpreted as &#8220;generic&#8221; functions know how to
calculate their return type automatically. For a listing of known generic
functions, see <a class="reference internal" href="functions.html#generic-functions"><em>SQL and Generic Functions</em></a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a> construct has only limited support for calling
standalone &#8220;stored procedures&#8221;, especially those with special
parameterization concerns.</p>
<p class="last">See the section <a class="reference internal" href="connections.html#stored-procedures"><em>Calling Stored Procedures</em></a> for details on how to use
the DBAPI-level <tt class="docutils literal"><span class="pre">callproc()</span></tt> method for fully traditional stored
procedures.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.label">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">label</tt><big>(</big><em>name</em>, <em>element</em>, <em>type_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.label" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <a class="reference internal" href="#sqlalchemy.sql.expression.Label" title="sqlalchemy.sql.expression.Label"><tt class="xref py py-class docutils literal"><span class="pre">Label</span></tt></a> object for the
given <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>.</p>
<p>A label changes the name of an element in the columns clause of a
<tt class="docutils literal"><span class="pre">SELECT</span></tt> statement, typically via the <tt class="docutils literal"><span class="pre">AS</span></tt> SQL keyword.</p>
<p>This functionality is more conveniently available via the
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.label" title="sqlalchemy.sql.expression.ColumnElement.label"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.label()</span></tt></a> method on <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>.</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.sql.expression.label.params.name"></span><strong>name</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.label.params.name">¶</a> &#8211; label name</li>
<li><span class="target" id="sqlalchemy.sql.expression.label.params.obj"></span><strong>obj</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.label.params.obj">¶</a> &#8211; a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.literal">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">literal</tt><big>(</big><em>value</em>, <em>type_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.literal" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a literal clause, bound to a bind parameter.</p>
<p>Literal clauses are created automatically when non-
<a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a> objects (such as strings, ints, dates, etc.) are
used in a comparison operation with a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> subclass,
such as a <a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> object.  Use this function
to force the generation of a literal clause, which will be created as a
<a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> with a bound value.</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.sql.expression.literal.params.value"></span><strong>value</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.literal.params.value">¶</a> &#8211; the value to be bound. Can be any Python object supported by
the underlying DB-API, or is translatable via the given type argument.</li>
<li><span class="target" id="sqlalchemy.sql.expression.literal.params.type_"></span><strong>type_</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.literal.params.type_">¶</a> &#8211; an optional <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">TypeEngine</span></tt></a> which
will provide bind-parameter translation for this literal.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.literal_column">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">literal_column</tt><big>(</big><em>text</em>, <em>type_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.literal_column" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> object that has the
<a class="reference internal" href="#sqlalchemy.sql.expression.column.params.is_literal" title="sqlalchemy.sql.expression.column"><tt class="xref py py-paramref docutils literal"><span class="pre">column.is_literal</span></tt></a> flag set to True.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.literal_column" title="sqlalchemy.sql.expression.literal_column"><tt class="xref py py-func docutils literal"><span class="pre">literal_column()</span></tt></a> is similar to <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a>, except that
it is more often used as a &#8220;standalone&#8221; column expression that renders
exactly as stated; while <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> stores a string name that
will be assumed to be part of a table and may be quoted as such,
<a class="reference internal" href="#sqlalchemy.sql.expression.literal_column" title="sqlalchemy.sql.expression.literal_column"><tt class="xref py py-func docutils literal"><span class="pre">literal_column()</span></tt></a> can be that, or any other arbitrary column-oriented
expression.</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.sql.expression.literal_column.params.text"></span><strong>text</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.literal_column.params.text">¶</a> &#8211; the text of the expression; can be any SQL expression.
Quoting rules will not be applied. To specify a column-name expression
which should be subject to quoting rules, use the <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a>
function.</li>
<li><span class="target" id="sqlalchemy.sql.expression.literal_column.params.type_"></span><strong>type_</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.literal_column.params.type_">¶</a> &#8211; an optional <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">TypeEngine</span></tt></a>
object which will
provide result-set translation and additional expression semantics for
this column. If left as None the type will be NullType.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a></p>
<p class="last"><a class="reference internal" href="tutorial.html#sqlexpression-literal-column"><em>Using More Specific Text with table(), literal_column(), and column()</em></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.not_">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">not_</tt><big>(</big><em>clause</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.not_" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a negation of the given clause, i.e. <tt class="docutils literal"><span class="pre">NOT(clause)</span></tt>.</p>
<p>The <tt class="docutils literal"><span class="pre">~</span></tt> operator is also overloaded on all
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> subclasses to produce the
same result.</p>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.null">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">null</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.null" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a constant <a class="reference internal" href="#sqlalchemy.sql.elements.Null" title="sqlalchemy.sql.elements.Null"><tt class="xref py py-class docutils literal"><span class="pre">Null</span></tt></a> construct.</p>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.nullsfirst">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">nullsfirst</tt><big>(</big><em>column</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.nullsfirst" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce the <tt class="docutils literal"><span class="pre">NULLS</span> <span class="pre">FIRST</span></tt> modifier for an <tt class="docutils literal"><span class="pre">ORDER</span> <span class="pre">BY</span></tt> expression.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.nullsfirst" title="sqlalchemy.sql.expression.nullsfirst"><tt class="xref py py-func docutils literal"><span class="pre">nullsfirst()</span></tt></a> is intended to modify the expression produced
by <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a> or <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a>, and indicates how NULL values
should be handled when they are encountered during ordering:</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">desc</span><span class="p">,</span> <span class="n">nullsfirst</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">order_by</span><span class="p">(</span><span class="n">nullsfirst</span><span class="p">(</span><span class="n">desc</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">)))</span></pre></div>
</div>
<p>The SQL expression from the above would resemble:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user ORDER BY name DESC NULLS FIRST</pre>
</div>
<p>Like <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a> and <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a>, <a class="reference internal" href="#sqlalchemy.sql.expression.nullsfirst" title="sqlalchemy.sql.expression.nullsfirst"><tt class="xref py py-func docutils literal"><span class="pre">nullsfirst()</span></tt></a> is typically
invoked from the column expression itself using
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.nullsfirst" title="sqlalchemy.sql.expression.ColumnElement.nullsfirst"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.nullsfirst()</span></tt></a>, rather than as its standalone
function version, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="p">(</span><span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>
        <span class="n">order_by</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">desc</span><span class="p">()</span><span class="o">.</span><span class="n">nullsfirst</span><span class="p">())</span>
        <span class="p">)</span></pre></div>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.nullslast" title="sqlalchemy.sql.expression.nullslast"><tt class="xref py py-func docutils literal"><span class="pre">nullslast()</span></tt></a></p>
<p class="last"><a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.order_by" title="sqlalchemy.sql.expression.Select.order_by"><tt class="xref py py-meth docutils literal"><span class="pre">Select.order_by()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.nullslast">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">nullslast</tt><big>(</big><em>column</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.nullslast" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce the <tt class="docutils literal"><span class="pre">NULLS</span> <span class="pre">LAST</span></tt> modifier for an <tt class="docutils literal"><span class="pre">ORDER</span> <span class="pre">BY</span></tt> expression.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.nullslast" title="sqlalchemy.sql.expression.nullslast"><tt class="xref py py-func docutils literal"><span class="pre">nullslast()</span></tt></a> is intended to modify the expression produced
by <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a> or <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a>, and indicates how NULL values
should be handled when they are encountered during ordering:</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">desc</span><span class="p">,</span> <span class="n">nullslast</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">order_by</span><span class="p">(</span><span class="n">nullslast</span><span class="p">(</span><span class="n">desc</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">)))</span></pre></div>
</div>
<p>The SQL expression from the above would resemble:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user ORDER BY name DESC NULLS LAST</pre>
</div>
<p>Like <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a> and <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a>, <a class="reference internal" href="#sqlalchemy.sql.expression.nullslast" title="sqlalchemy.sql.expression.nullslast"><tt class="xref py py-func docutils literal"><span class="pre">nullslast()</span></tt></a> is typically
invoked from the column expression itself using
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.nullslast" title="sqlalchemy.sql.expression.ColumnElement.nullslast"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnElement.nullslast()</span></tt></a>, rather than as its standalone
function version, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">order_by</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">desc</span><span class="p">()</span><span class="o">.</span><span class="n">nullslast</span><span class="p">())</span></pre></div>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.nullsfirst" title="sqlalchemy.sql.expression.nullsfirst"><tt class="xref py py-func docutils literal"><span class="pre">nullsfirst()</span></tt></a></p>
<p class="last"><a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.order_by" title="sqlalchemy.sql.expression.Select.order_by"><tt class="xref py py-meth docutils literal"><span class="pre">Select.order_by()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.or_">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">or_</tt><big>(</big><em>*clauses</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.or_" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a conjunction of expressions joined by <tt class="docutils literal"><span class="pre">OR</span></tt>.</p>
<p>E.g.:</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">or_</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span>
                <span class="n">or_</span><span class="p">(</span>
                    <span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">,</span>
                    <span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;jack&#39;</span>
                <span class="p">)</span>
            <span class="p">)</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.or_" title="sqlalchemy.sql.expression.or_"><tt class="xref py py-func docutils literal"><span class="pre">or_()</span></tt></a> conjunction is also available using the
Python <tt class="docutils literal"><span class="pre">|</span></tt> operator (though note that compound expressions
need to be parenthesized in order to function with Python
operator precedence behavior):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span>
                <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">)</span> <span class="o">|</span>
                <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;jack&#39;</span><span class="p">)</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="#sqlalchemy.sql.expression.and_" title="sqlalchemy.sql.expression.and_"><tt class="xref py py-func docutils literal"><span class="pre">and_()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.outparam">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">outparam</tt><big>(</big><em>key</em>, <em>type_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.outparam" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an &#8216;OUT&#8217; parameter for usage in functions (stored procedures),
for databases which support them.</p>
<p>The <tt class="docutils literal"><span class="pre">outparam</span></tt> can be used like a regular function parameter.
The &#8220;output&#8221; value will be available from the
<a class="reference internal" href="connections.html#sqlalchemy.engine.ResultProxy" title="sqlalchemy.engine.ResultProxy"><tt class="xref py py-class docutils literal"><span class="pre">ResultProxy</span></tt></a> object via its <tt class="docutils literal"><span class="pre">out_parameters</span></tt>
attribute, which returns a dictionary containing the values.</p>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.over">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">over</tt><big>(</big><em>func</em>, <em>partition_by=None</em>, <em>order_by=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.over" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce an <a class="reference internal" href="#sqlalchemy.sql.expression.Over" title="sqlalchemy.sql.expression.Over"><tt class="xref py py-class docutils literal"><span class="pre">Over</span></tt></a> object against a function.</p>
<p>Used against aggregate or so-called &#8220;window&#8221; functions,
for database backends that support window functions.</p>
<p>E.g.:</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">over</span>
<span class="n">over</span><span class="p">(</span><span class="n">func</span><span class="o">.</span><span class="n">row_number</span><span class="p">(),</span> <span class="n">order_by</span><span class="o">=</span><span class="s">&#39;x&#39;</span><span class="p">)</span></pre></div>
</div>
<p>Would produce &#8220;ROW_NUMBER() OVER(ORDER BY x)&#8221;.</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.sql.expression.over.params.func"></span><strong>func</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.over.params.func">¶</a> &#8211; a <a class="reference internal" href="functions.html#sqlalchemy.sql.functions.FunctionElement" title="sqlalchemy.sql.functions.FunctionElement"><tt class="xref py py-class docutils literal"><span class="pre">FunctionElement</span></tt></a> construct, typically
generated by <a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a>.</li>
<li><span class="target" id="sqlalchemy.sql.expression.over.params.partition_by"></span><strong>partition_by</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.over.params.partition_by">¶</a> &#8211; a column element or string, or a list
of such, that will be used as the PARTITION BY clause
of the OVER construct.</li>
<li><span class="target" id="sqlalchemy.sql.expression.over.params.order_by"></span><strong>order_by</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.over.params.order_by">¶</a> &#8211; a column element or string, or a list
of such, that will be used as the ORDER BY clause
of the OVER construct.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>This function is also available from the <a class="reference internal" href="#sqlalchemy.sql.expression.func" title="sqlalchemy.sql.expression.func"><tt class="xref py py-data docutils literal"><span class="pre">func</span></tt></a>
construct itself via the <a class="reference internal" href="functions.html#sqlalchemy.sql.functions.FunctionElement.over" title="sqlalchemy.sql.functions.FunctionElement.over"><tt class="xref py py-meth docutils literal"><span class="pre">FunctionElement.over()</span></tt></a> method.</p>
<div class="versionadded">
<p><span>New in version 0.7.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.text">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">text</tt><big>(</big><em>text</em>, <em>bind=None</em>, <em>bindparams=None</em>, <em>typemap=None</em>, <em>autocommit=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.text" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause" title="sqlalchemy.sql.expression.TextClause"><tt class="xref py py-class docutils literal"><span class="pre">TextClause</span></tt></a> clause, representing
a textual SQL string directly.</p>
<p>E.g.:</p>
<div class="highlight-python"><pre>fom sqlalchemy import text

t = text("SELECT * FROM users")
result = connection.execute(t)</pre>
</div>
<p>The advantages <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a> provides over a plain string are
backend-neutral support for bind parameters, per-statement
execution options, as well as
bind parameter and result-column typing behavior, allowing
SQLAlchemy type constructs to play a role when executing
a statement that is specified literally.  The construct can also
be provided with a <tt class="docutils literal"><span class="pre">.c</span></tt> collection of column elements, allowing
it to be embedded in other SQL expression constructs as a subquery.</p>
<p>Bind parameters are specified by name, using the format <tt class="docutils literal"><span class="pre">:name</span></tt>.
E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">t</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM users WHERE id=:user_id&quot;</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">user_id</span><span class="o">=</span><span class="mi">12</span><span class="p">)</span></pre></div>
</div>
<p>For SQL statements where a colon is required verbatim, as within
an inline string, use a backslash to escape:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">t</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM users WHERE name=&#39;\:username&#39;&quot;</span><span class="p">)</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause" title="sqlalchemy.sql.expression.TextClause"><tt class="xref py py-class docutils literal"><span class="pre">TextClause</span></tt></a> construct includes methods which can
provide information about the bound parameters as well as the column
values which would be returned from the textual statement, assuming
it&#8217;s an executable SELECT type of statement.  The
<a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.bindparams" title="sqlalchemy.sql.expression.TextClause.bindparams"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.bindparams()</span></tt></a> method is used to provide bound
parameter detail, and <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.columns" title="sqlalchemy.sql.expression.TextClause.columns"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.columns()</span></tt></a> method allows
specification of return columns including names and types:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">t</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM users WHERE id=:user_id&quot;</span><span class="p">)</span><span class="o">.</span>\
        <span class="n">bindparams</span><span class="p">(</span><span class="n">user_id</span><span class="o">=</span><span class="mi">7</span><span class="p">)</span><span class="o">.</span>\
        <span class="n">columns</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">Integer</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">String</span><span class="p">)</span>

<span class="k">for</span> <span class="nb">id</span><span class="p">,</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">t</span><span class="p">):</span>
    <span class="k">print</span><span class="p">(</span><span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a> construct is used internally in cases when
a literal string is specified for part of a larger query, such as
when a string is specified to the <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.where" title="sqlalchemy.sql.expression.Select.where"><tt class="xref py py-meth docutils literal"><span class="pre">Select.where()</span></tt></a> method of
<a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select" title="sqlalchemy.sql.expression.Select"><tt class="xref py py-class docutils literal"><span class="pre">Select</span></tt></a>.  In those cases, the same
bind parameter syntax is applied:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">s</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="n">users</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="s">&quot;id=:user_id&quot;</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">user_id</span><span class="o">=</span><span class="mi">12</span><span class="p">)</span></pre></div>
</div>
<p>Using <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a> explicitly usually implies the construction
of a full, standalone statement.   As such, SQLAlchemy refers
to it as an <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Executable" title="sqlalchemy.sql.expression.Executable"><tt class="xref py py-class docutils literal"><span class="pre">Executable</span></tt></a> object, and it supports
the <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Executable.execution_options" title="sqlalchemy.sql.expression.Executable.execution_options"><tt class="xref py py-meth docutils literal"><span class="pre">Executable.execution_options()</span></tt></a> method.  For example,
a <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a> construct that should be subject to &#8220;autocommit&#8221;
can be set explicitly so using the
<a class="reference internal" href="connections.html#sqlalchemy.engine.Connection.execution_options.params.autocommit" title="sqlalchemy.engine.Connection.execution_options"><tt class="xref py py-paramref docutils literal"><span class="pre">Connection.execution_options.autocommit</span></tt></a> option:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">t</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;EXEC my_procedural_thing()&quot;</span><span class="p">)</span><span class="o">.</span>\
        <span class="n">execution_options</span><span class="p">(</span><span class="n">autocommit</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span></pre></div>
</div>
<p>Note that SQLAlchemy&#8217;s usual &#8220;autocommit&#8221; behavior applies to
<a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a> constructs implicitly - that is, statements which begin
with a phrase such as <tt class="docutils literal"><span class="pre">INSERT</span></tt>, <tt class="docutils literal"><span class="pre">UPDATE</span></tt>, <tt class="docutils literal"><span class="pre">DELETE</span></tt>,
or a variety of other phrases specific to certain backends, will
be eligible for autocommit if no transaction is in progress.</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.sql.expression.text.params.text"></span><strong>text</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.text.params.text">¶</a> &#8211; the text of the SQL statement to be created.  use <tt class="docutils literal"><span class="pre">:&lt;param&gt;</span></tt>
to specify bind parameters; they will be compiled to their
engine-specific format.</li>
<li><span class="target" id="sqlalchemy.sql.expression.text.params.autocommit"></span><strong>autocommit</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.text.params.autocommit">¶</a> &#8211; Deprecated.  Use .execution_options(autocommit=&lt;True|False&gt;)
to set the autocommit option.</li>
<li><span class="target" id="sqlalchemy.sql.expression.text.params.bind"></span><strong>bind</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.text.params.bind">¶</a> &#8211; an optional connection or engine to be used for this text query.</li>
<li><span class="target" id="sqlalchemy.sql.expression.text.params.bindparams"></span><strong>bindparams</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.text.params.bindparams">¶</a> &#8211; <p>Deprecated.  A list of <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> instances used to
provide information about parameters embedded in the statement.
This argument now invokes the <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.bindparams" title="sqlalchemy.sql.expression.TextClause.bindparams"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.bindparams()</span></tt></a>
method on the construct before returning it.  E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM table WHERE id=:id&quot;</span><span class="p">,</span>
          <span class="n">bindparams</span><span class="o">=</span><span class="p">[</span><span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;id&#39;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">Integer</span><span class="p">)])</span></pre></div>
</div>
<p>Is equivalent to:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM table WHERE id=:id&quot;</span><span class="p">)</span><span class="o">.</span>\
          <span class="n">bindparams</span><span class="p">(</span><span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;id&#39;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">Integer</span><span class="p">))</span></pre></div>
</div>
<div class="deprecated">
<p><span>Deprecated since version 0.9.0: </span>the <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.bindparams" title="sqlalchemy.sql.expression.TextClause.bindparams"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.bindparams()</span></tt></a> method
supersedes the <tt class="docutils literal"><span class="pre">bindparams</span></tt> argument to <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a>.</p>
</div>
</li>
<li><span class="target" id="sqlalchemy.sql.expression.text.params.typemap"></span><strong>typemap</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.text.params.typemap">¶</a> &#8211; <p>Deprecated.  A dictionary mapping the names of columns
represented in the columns clause of a <tt class="docutils literal"><span class="pre">SELECT</span></tt> statement
to type objects,
which will be used to perform post-processing on columns within
the result set.  This parameter now invokes the
<a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.columns" title="sqlalchemy.sql.expression.TextClause.columns"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.columns()</span></tt></a> method, which returns a
<a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.TextAsFrom" title="sqlalchemy.sql.expression.TextAsFrom"><tt class="xref py py-class docutils literal"><span class="pre">TextAsFrom</span></tt></a> construct that gains a <tt class="docutils literal"><span class="pre">.c</span></tt> collection and
can be embedded in other expressions.  E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM table&quot;</span><span class="p">,</span>
              <span class="n">typemap</span><span class="o">=</span><span class="p">{</span><span class="s">&#39;id&#39;</span><span class="p">:</span> <span class="n">Integer</span><span class="p">,</span> <span class="s">&#39;name&#39;</span><span class="p">:</span> <span class="n">String</span><span class="p">},</span>
          <span class="p">)</span></pre></div>
</div>
<p>Is equivalent to:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM table&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">columns</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">Integer</span><span class="p">,</span>
                                           <span class="n">name</span><span class="o">=</span><span class="n">String</span><span class="p">)</span></pre></div>
</div>
<p>Or alternatively:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">column</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM table&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">columns</span><span class="p">(</span>
                      <span class="n">column</span><span class="p">(</span><span class="s">&#39;id&#39;</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">&#39;name&#39;</span><span class="p">,</span> <span class="n">String</span><span class="p">)</span>
                  <span class="p">)</span></pre></div>
</div>
<div class="deprecated">
<p><span>Deprecated since version 0.9.0: </span>the <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.columns" title="sqlalchemy.sql.expression.TextClause.columns"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.columns()</span></tt></a> method
supersedes the <tt class="docutils literal"><span class="pre">typemap</span></tt> argument to <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a>.</p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.true">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">true</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.true" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a constant <a class="reference internal" href="#sqlalchemy.sql.elements.True_" title="sqlalchemy.sql.elements.True_"><tt class="xref py py-class docutils literal"><span class="pre">True_</span></tt></a> construct.</p>
<p>E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sqlalchemy</span> <span class="kn">import</span> <span class="n">true</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">true</span><span class="p">())</span>
<span class="go">SELECT x FROM t WHERE true</span></pre></div>
</div>
<p>A backend which does not support true/false constants will render as
an expression against 1 or 0:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">true</span><span class="p">())</span>
<span class="go">SELECT x FROM t WHERE 1 = 1</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.true" title="sqlalchemy.sql.expression.true"><tt class="xref py py-func docutils literal"><span class="pre">true()</span></tt></a> and <a class="reference internal" href="#sqlalchemy.sql.expression.false" title="sqlalchemy.sql.expression.false"><tt class="xref py py-func docutils literal"><span class="pre">false()</span></tt></a> constants also feature
&#8220;short circuit&#8221; operation within an <a class="reference internal" href="#sqlalchemy.sql.expression.and_" title="sqlalchemy.sql.expression.and_"><tt class="xref py py-func docutils literal"><span class="pre">and_()</span></tt></a> or <a class="reference internal" href="#sqlalchemy.sql.expression.or_" title="sqlalchemy.sql.expression.or_"><tt class="xref py py-func docutils literal"><span class="pre">or_()</span></tt></a>
conjunction:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">or_</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span> <span class="o">&gt;</span> <span class="mi">5</span><span class="p">,</span> <span class="n">true</span><span class="p">()))</span>
<span class="go">SELECT x FROM t WHERE true</span>

<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">and_</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span> <span class="o">&gt;</span> <span class="mi">5</span><span class="p">,</span> <span class="n">false</span><span class="p">()))</span>
<span class="go">SELECT x FROM t WHERE false</span></pre></div>
</div>
<div class="versionchanged">
<p><span>Changed in version 0.9: </span><a class="reference internal" href="#sqlalchemy.sql.expression.true" title="sqlalchemy.sql.expression.true"><tt class="xref py py-func docutils literal"><span class="pre">true()</span></tt></a> and <a class="reference internal" href="#sqlalchemy.sql.expression.false" title="sqlalchemy.sql.expression.false"><tt class="xref py py-func docutils literal"><span class="pre">false()</span></tt></a> feature
better integrated behavior within conjunctions and on dialects
that don&#8217;t support true/false constants.</p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.false" title="sqlalchemy.sql.expression.false"><tt class="xref py py-func docutils literal"><span class="pre">false()</span></tt></a></p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.tuple_">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">tuple_</tt><big>(</big><em>*clauses</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.tuple_" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <a class="reference internal" href="#sqlalchemy.sql.expression.Tuple" title="sqlalchemy.sql.expression.Tuple"><tt class="xref py py-class docutils literal"><span class="pre">Tuple</span></tt></a>.</p>
<p>Main usage is to produce a composite IN construct:</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">tuple_</span>

<span class="n">tuple_</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">col1</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">col2</span><span class="p">)</span><span class="o">.</span><span class="n">in_</span><span class="p">(</span>
    <span class="p">[(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">12</span><span class="p">),</span> <span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">19</span><span class="p">)]</span>
<span class="p">)</span></pre></div>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">The composite IN construct is not supported by all backends,
and is currently known to work on Postgresql and MySQL,
but not SQLite.   Unsupported backends will raise
a subclass of <a class="reference internal" href="exceptions.html#sqlalchemy.exc.DBAPIError" title="sqlalchemy.exc.DBAPIError"><tt class="xref py py-class docutils literal"><span class="pre">DBAPIError</span></tt></a> when such
an expression is invoked.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="sqlalchemy.sql.expression.type_coerce">
<tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">type_coerce</tt><big>(</big><em>expression</em>, <em>type_</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.type_coerce" title="Permalink to this definition">¶</a></dt>
<dd><p>Associate a SQL expression with a particular type, without rendering
<tt class="docutils literal"><span class="pre">CAST</span></tt>.</p>
<p>E.g.:</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">type_coerce</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">type_coerce</span><span class="p">(</span><span class="n">log_table</span><span class="o">.</span><span class="n">date_string</span><span class="p">,</span> <span class="n">StringDateTime</span><span class="p">())])</span></pre></div>
</div>
<p>The above construct will produce SQL that is usually otherwise unaffected
by the <a class="reference internal" href="#sqlalchemy.sql.expression.type_coerce" title="sqlalchemy.sql.expression.type_coerce"><tt class="xref py py-func docutils literal"><span class="pre">type_coerce()</span></tt></a> call:</p>
<div class="highlight-python"><pre>SELECT date_string FROM log</pre>
</div>
<p>However, when result rows are fetched, the <tt class="docutils literal"><span class="pre">StringDateTime</span></tt> type
will be applied to result rows on behalf of the <tt class="docutils literal"><span class="pre">date_string</span></tt> column.</p>
<p>A type that features bound-value handling will also have that behavior
take effect when literal values or <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> constructs are
passed to <a class="reference internal" href="#sqlalchemy.sql.expression.type_coerce" title="sqlalchemy.sql.expression.type_coerce"><tt class="xref py py-func docutils literal"><span class="pre">type_coerce()</span></tt></a> as targets.
For example, if a type implements the <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine.bind_expression" title="sqlalchemy.types.TypeEngine.bind_expression"><tt class="xref py py-meth docutils literal"><span class="pre">TypeEngine.bind_expression()</span></tt></a>
method or <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine.bind_processor" title="sqlalchemy.types.TypeEngine.bind_processor"><tt class="xref py py-meth docutils literal"><span class="pre">TypeEngine.bind_processor()</span></tt></a> method or equivalent,
these functions will take effect at statement compilation/execution time
when a literal value is passed, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># bound-value handling of MyStringType will be applied to the</span>
<span class="c"># literal value &quot;some string&quot;</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">type_coerce</span><span class="p">(</span><span class="s">&quot;some string&quot;</span><span class="p">,</span> <span class="n">MyStringType</span><span class="p">)])</span></pre></div>
</div>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.type_coerce" title="sqlalchemy.sql.expression.type_coerce"><tt class="xref py py-func docutils literal"><span class="pre">type_coerce()</span></tt></a> is similar to the <a class="reference internal" href="#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,
except that it does not render the <tt class="docutils literal"><span class="pre">CAST</span></tt> expression in the resulting
statement.</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.sql.expression.type_coerce.params.expression"></span><strong>expression</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.type_coerce.params.expression">¶</a> &#8211; A SQL expression, such as a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>
expression or a Python string which will be coerced into a bound literal
value.</li>
<li><span class="target" id="sqlalchemy.sql.expression.type_coerce.params.type_"></span><strong>type_</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.type_coerce.params.type_">¶</a> &#8211; A <a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">TypeEngine</span></tt></a> class or instance indicating
the type to which the expression is coerced.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a></p>
</div>
</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.BinaryExpression">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">BinaryExpression</tt><big>(</big><em>left</em>, <em>right</em>, <em>operator</em>, <em>type_=None</em>, <em>negate=None</em>, <em>modifiers=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.BinaryExpression" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent an expression that is <tt class="docutils literal"><span class="pre">LEFT</span> <span class="pre">&lt;operator&gt;</span> <span class="pre">RIGHT</span></tt>.</p>
<p>A <a class="reference internal" href="#sqlalchemy.sql.expression.BinaryExpression" title="sqlalchemy.sql.expression.BinaryExpression"><tt class="xref py py-class docutils literal"><span class="pre">BinaryExpression</span></tt></a> is generated automatically
whenever two column expressions are used in a Python binary expression:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">column</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">column</span><span class="p">(</span><span class="s">&#39;a&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;b&#39;</span><span class="p">)</span>
<span class="go">&lt;sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;a&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;b&#39;</span><span class="p">)</span>
<span class="go">a + b</span></pre></div>
</div>
<dl class="method">
<dt id="sqlalchemy.sql.expression.BinaryExpression.compare">
<tt class="descname">compare</tt><big>(</big><em>other</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.BinaryExpression.compare" title="Permalink to this definition">¶</a></dt>
<dd><p>Compare this <a class="reference internal" href="#sqlalchemy.sql.expression.BinaryExpression" title="sqlalchemy.sql.expression.BinaryExpression"><tt class="xref py py-class docutils literal"><span class="pre">BinaryExpression</span></tt></a> against the
given <a class="reference internal" href="#sqlalchemy.sql.expression.BinaryExpression" title="sqlalchemy.sql.expression.BinaryExpression"><tt class="xref py py-class docutils literal"><span class="pre">BinaryExpression</span></tt></a>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.BindParameter">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">BindParameter</tt><big>(</big><em>key</em>, <em>value=symbol('NO_ARG')</em>, <em>type_=None</em>, <em>unique=False</em>, <em>required=symbol('NO_ARG')</em>, <em>quote=None</em>, <em>callable_=None</em>, <em>isoutparam=False</em>, <em>_compared_to_operator=None</em>, <em>_compared_to_type=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.BindParameter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent a &#8220;bound expression&#8221;.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> is invoked explicitly using the
<a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> function, as in:</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">bindparam</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">where</span><span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;username&#39;</span><span class="p">))</span></pre></div>
</div>
<p>Detailed discussion of how <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> is used is
at <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a>.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a></p>
</div>
<dl class="method">
<dt id="sqlalchemy.sql.expression.BindParameter.__init__">
<tt class="descname">__init__</tt><big>(</big><em>key</em>, <em>value=symbol('NO_ARG')</em>, <em>type_=None</em>, <em>unique=False</em>, <em>required=symbol('NO_ARG')</em>, <em>quote=None</em>, <em>callable_=None</em>, <em>isoutparam=False</em>, <em>_compared_to_operator=None</em>, <em>_compared_to_type=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.BindParameter.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> object.</p>
<p>This constructor is mirrored as a public API function; see <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> for a full usage and argument description.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.BindParameter.compare">
<tt class="descname">compare</tt><big>(</big><em>other</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.BindParameter.compare" title="Permalink to this definition">¶</a></dt>
<dd><p>Compare this <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> to the given
clause.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.BindParameter.effective_value">
<tt class="descname">effective_value</tt><a class="headerlink" href="#sqlalchemy.sql.expression.BindParameter.effective_value" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the value of this bound parameter,
taking into account if the <tt class="docutils literal"><span class="pre">callable</span></tt> parameter
was set.</p>
<p>The <tt class="docutils literal"><span class="pre">callable</span></tt> value will be evaluated
and returned if present, else <tt class="docutils literal"><span class="pre">value</span></tt>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.Case">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">Case</tt><big>(</big><em>whens</em>, <em>value=None</em>, <em>else_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Case" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent a <tt class="docutils literal"><span class="pre">CASE</span></tt> expression.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.Case" title="sqlalchemy.sql.expression.Case"><tt class="xref py py-class docutils literal"><span class="pre">Case</span></tt></a> is produced using the <a class="reference internal" href="#sqlalchemy.sql.expression.case" title="sqlalchemy.sql.expression.case"><tt class="xref py py-func docutils literal"><span class="pre">case()</span></tt></a> factory function,
as in:</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">case</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">users_table</span><span class="p">])</span><span class="o">.</span>\
            <span class="n">where</span><span class="p">(</span>
                <span class="n">case</span><span class="p">(</span>
                    <span class="p">[</span>
                        <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;wendy&#39;</span><span class="p">,</span> <span class="s">&#39;W&#39;</span><span class="p">),</span>
                        <span class="p">(</span><span class="n">users_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;jack&#39;</span><span class="p">,</span> <span class="s">&#39;J&#39;</span><span class="p">)</span>
                    <span class="p">],</span>
                    <span class="n">else_</span><span class="o">=</span><span class="s">&#39;E&#39;</span>
                <span class="p">)</span>
            <span class="p">)</span></pre></div>
</div>
<p>Details on <a class="reference internal" href="#sqlalchemy.sql.expression.Case" title="sqlalchemy.sql.expression.Case"><tt class="xref py py-class docutils literal"><span class="pre">Case</span></tt></a> usage is at <a class="reference internal" href="#sqlalchemy.sql.expression.case" title="sqlalchemy.sql.expression.case"><tt class="xref py py-func docutils literal"><span class="pre">case()</span></tt></a>.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.case" title="sqlalchemy.sql.expression.case"><tt class="xref py py-func docutils literal"><span class="pre">case()</span></tt></a></p>
</div>
<dl class="method">
<dt id="sqlalchemy.sql.expression.Case.__init__">
<tt class="descname">__init__</tt><big>(</big><em>whens</em>, <em>value=None</em>, <em>else_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Case.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.Case" title="sqlalchemy.sql.expression.Case"><tt class="xref py py-class docutils literal"><span class="pre">Case</span></tt></a> object.</p>
<p>This constructor is mirrored as a public API function; see <a class="reference internal" href="#sqlalchemy.sql.expression.case" title="sqlalchemy.sql.expression.case"><tt class="xref py py-func docutils literal"><span class="pre">case()</span></tt></a> for a full usage and argument description.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.Cast">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">Cast</tt><big>(</big><em>expression</em>, <em>type_</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Cast" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent a <tt class="docutils literal"><span class="pre">CAST</span></tt> expression.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.Cast" title="sqlalchemy.sql.expression.Cast"><tt class="xref py py-class docutils literal"><span class="pre">Cast</span></tt></a> is produced using the <a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a> factory function,
as in:</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">cast</span><span class="p">,</span> <span class="n">Numeric</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span>
            <span class="n">cast</span><span class="p">(</span><span class="n">product_table</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">unit_price</span><span class="p">,</span> <span class="n">Numeric</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
        <span class="p">])</span></pre></div>
</div>
<p>Details on <a class="reference internal" href="#sqlalchemy.sql.expression.Cast" title="sqlalchemy.sql.expression.Cast"><tt class="xref py py-class docutils literal"><span class="pre">Cast</span></tt></a> usage is at <a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a>.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a></p>
</div>
<dl class="method">
<dt id="sqlalchemy.sql.expression.Cast.__init__">
<tt class="descname">__init__</tt><big>(</big><em>expression</em>, <em>type_</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Cast.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.Cast" title="sqlalchemy.sql.expression.Cast"><tt class="xref py py-class docutils literal"><span class="pre">Cast</span></tt></a> object.</p>
<p>This constructor is mirrored as a public API function; see <a class="reference internal" href="#sqlalchemy.sql.expression.cast" title="sqlalchemy.sql.expression.cast"><tt class="xref py py-func docutils literal"><span class="pre">cast()</span></tt></a> for a full usage and argument description.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.ClauseElement">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">ClauseElement</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseElement" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.visitors.Visitable</span></tt></p>
<p>Base class for elements of a programmatically constructed SQL
expression.</p>
<dl class="method">
<dt id="sqlalchemy.sql.expression.ClauseElement.compare">
<tt class="descname">compare</tt><big>(</big><em>other</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseElement.compare" title="Permalink to this definition">¶</a></dt>
<dd><p>Compare this ClauseElement to the given ClauseElement.</p>
<p>Subclasses should override the default behavior, which is a
straight identity comparison.</p>
<p>**kw are arguments consumed by subclass compare() methods and
may be used to modify the criteria for comparison.
(see <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>)</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ClauseElement.compile">
<tt class="descname">compile</tt><big>(</big><em>bind=None</em>, <em>dialect=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseElement.compile" title="Permalink to this definition">¶</a></dt>
<dd><p>Compile this SQL expression.</p>
<p>The return value is a <a class="reference internal" href="internals.html#sqlalchemy.engine.interfaces.Compiled" title="sqlalchemy.engine.interfaces.Compiled"><tt class="xref py py-class docutils literal"><span class="pre">Compiled</span></tt></a> object.
Calling <tt class="docutils literal"><span class="pre">str()</span></tt> or <tt class="docutils literal"><span class="pre">unicode()</span></tt> on the returned value will yield a
string representation of the result. The
<a class="reference internal" href="internals.html#sqlalchemy.engine.interfaces.Compiled" title="sqlalchemy.engine.interfaces.Compiled"><tt class="xref py py-class docutils literal"><span class="pre">Compiled</span></tt></a> object also can return a
dictionary of bind parameter names and values
using the <tt class="docutils literal"><span class="pre">params</span></tt> accessor.</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.sql.expression.ClauseElement.compile.params.bind"></span><strong>bind</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ClauseElement.compile.params.bind">¶</a> &#8211; An <tt class="docutils literal"><span class="pre">Engine</span></tt> or <tt class="docutils literal"><span class="pre">Connection</span></tt> from which a
<tt class="docutils literal"><span class="pre">Compiled</span></tt> will be acquired. This argument takes precedence over
this <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>&#8216;s bound engine, if any.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ClauseElement.compile.params.column_keys"></span><strong>column_keys</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ClauseElement.compile.params.column_keys">¶</a> &#8211; Used for INSERT and UPDATE statements, a list of
column names which should be present in the VALUES clause of the
compiled statement. If <tt class="docutils literal"><span class="pre">None</span></tt>, all columns from the target table
object are rendered.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ClauseElement.compile.params.dialect"></span><strong>dialect</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ClauseElement.compile.params.dialect">¶</a> &#8211; A <tt class="docutils literal"><span class="pre">Dialect</span></tt> instance from which a <tt class="docutils literal"><span class="pre">Compiled</span></tt>
will be acquired. This argument takes precedence over the <cite>bind</cite>
argument as well as this <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>&#8216;s bound engine,
if any.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ClauseElement.compile.params.inline"></span><strong>inline</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ClauseElement.compile.params.inline">¶</a> &#8211; Used for INSERT statements, for a dialect which does
not support inline retrieval of newly generated primary key
columns, will force the expression used to create the new primary
key value to be rendered inline within the INSERT statement&#8217;s
VALUES clause. This typically refers to Sequence execution but may
also refer to any server-side default generation function
associated with a primary key <cite>Column</cite>.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ClauseElement.compile.params.compile_kwargs"></span><strong>compile_kwargs</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ClauseElement.compile.params.compile_kwargs">¶</a> &#8211; <p>optional dictionary of additional parameters
that will be passed through to the compiler within all &#8220;visit&#8221;
methods.  This allows any custom flag to be passed through to
a custom compilation construct, for example.  It is also used
for the case of passing the <tt class="docutils literal"><span class="pre">literal_binds</span></tt> flag through:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">table</span><span class="p">,</span> <span class="n">column</span><span class="p">,</span> <span class="n">select</span>

<span class="n">t</span> <span class="o">=</span> <span class="n">table</span><span class="p">(</span><span class="s">&#39;t&#39;</span><span class="p">,</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;x&#39;</span><span class="p">))</span>

<span class="n">s</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span> <span class="o">==</span> <span class="mi">5</span><span class="p">)</span>

<span class="k">print</span> <span class="n">s</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">compile_kwargs</span><span class="o">=</span><span class="p">{</span><span class="s">&quot;literal_binds&quot;</span><span class="p">:</span> <span class="bp">True</span><span class="p">})</span></pre></div>
</div>
<div class="versionadded">
<p><span>New in version 0.9.0.</span></p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="../faq.html#faq-sql-expression-string"><em>How do I render SQL expressions as strings, possibly with bound parameters inlined?</em></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ClauseElement.get_children">
<tt class="descname">get_children</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseElement.get_children" title="Permalink to this definition">¶</a></dt>
<dd><p>Return immediate child elements of this <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>.</p>
<p>This is used for visit traversal.</p>
<p>**kwargs may contain flags that change the collection that is
returned, for example to return a subset of items in order to
cut down on larger traversals, or to return child items from a
different context (such as schema-level collections instead of
clause-level).</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ClauseElement.params">
<tt class="descname">params</tt><big>(</big><em>*optionaldict</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseElement.params" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a copy with <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> elements replaced.</p>
<p>Returns a copy of this ClauseElement with <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a>
elements replaced with values taken from the given dictionary:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">clause</span> <span class="o">=</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;x&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">clause</span><span class="o">.</span><span class="n">compile</span><span class="p">()</span><span class="o">.</span><span class="n">params</span>
<span class="go">{&#39;foo&#39;:None}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">clause</span><span class="o">.</span><span class="n">params</span><span class="p">({</span><span class="s">&#39;foo&#39;</span><span class="p">:</span><span class="mi">7</span><span class="p">})</span><span class="o">.</span><span class="n">compile</span><span class="p">()</span><span class="o">.</span><span class="n">params</span>
<span class="go">{&#39;foo&#39;:7}</span></pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ClauseElement.self_group">
<tt class="descname">self_group</tt><big>(</big><em>against=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseElement.self_group" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply a &#8216;grouping&#8217; to this <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>.</p>
<p>This method is overridden by subclasses to return a
&#8220;grouping&#8221; construct, i.e. parenthesis.   In particular
it&#8217;s used by &#8220;binary&#8221; expressions to provide a grouping
around themselves when placed into a larger expression,
as well as by <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.select" title="sqlalchemy.sql.expression.select"><tt class="xref py py-func docutils literal"><span class="pre">select()</span></tt></a> constructs when placed into
the FROM clause of another <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.select" title="sqlalchemy.sql.expression.select"><tt class="xref py py-func docutils literal"><span class="pre">select()</span></tt></a>.  (Note that
subqueries should be normally created using the
<a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Select.alias" title="sqlalchemy.sql.expression.Select.alias"><tt class="xref py py-meth docutils literal"><span class="pre">Select.alias()</span></tt></a> method, as many platforms require
nested SELECT statements to be named).</p>
<p>As expressions are composed together, the application of
<a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement.self_group" title="sqlalchemy.sql.expression.ClauseElement.self_group"><tt class="xref py py-meth docutils literal"><span class="pre">self_group()</span></tt></a> is automatic - end-user code should never
need to use this method directly.  Note that SQLAlchemy&#8217;s
clause constructs take operator precedence into account -
so parenthesis might not be needed, for example, in
an expression like <tt class="docutils literal"><span class="pre">x</span> <span class="pre">OR</span> <span class="pre">(y</span> <span class="pre">AND</span> <span class="pre">z)</span></tt> - AND takes precedence
over OR.</p>
<p>The base <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement.self_group" title="sqlalchemy.sql.expression.ClauseElement.self_group"><tt class="xref py py-meth docutils literal"><span class="pre">self_group()</span></tt></a> method of <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>
just returns self.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ClauseElement.unique_params">
<tt class="descname">unique_params</tt><big>(</big><em>*optionaldict</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseElement.unique_params" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a copy with <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> elements replaced.</p>
<p>Same functionality as <tt class="docutils literal"><span class="pre">params()</span></tt>, except adds <cite>unique=True</cite>
to affected bind parameters so that multiple statements can be
used.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.ClauseList">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">ClauseList</tt><big>(</big><em>*clauses</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseList" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ClauseElement</span></tt></a></p>
<p>Describe a list of clauses, separated by an operator.</p>
<p>By default, is comma-separated, such as a column listing.</p>
<dl class="method">
<dt id="sqlalchemy.sql.expression.ClauseList.compare">
<tt class="descname">compare</tt><big>(</big><em>other</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ClauseList.compare" title="Permalink to this definition">¶</a></dt>
<dd><p>Compare this <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseList" title="sqlalchemy.sql.expression.ClauseList"><tt class="xref py py-class docutils literal"><span class="pre">ClauseList</span></tt></a> to the given <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseList" title="sqlalchemy.sql.expression.ClauseList"><tt class="xref py py-class docutils literal"><span class="pre">ClauseList</span></tt></a>,
including a comparison of all the clause items.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.ColumnClause">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">ColumnClause</tt><big>(</big><em>text</em>, <em>type_=None</em>, <em>is_literal=False</em>, <em>_selectable=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnClause" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.Immutable</span></tt>, <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represents a column expression from any textual string.</p>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a>, a lightweight analogue to the
<a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> class, is typically invoked using the
<a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> function, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">column</span>

<span class="nb">id</span><span class="p">,</span> <span class="n">name</span> <span class="o">=</span> <span class="n">column</span><span class="p">(</span><span class="s">&quot;id&quot;</span><span class="p">),</span> <span class="n">column</span><span class="p">(</span><span class="s">&quot;name&quot;</span><span class="p">)</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">])</span><span class="o">.</span><span class="n">select_from</span><span class="p">(</span><span class="s">&quot;user&quot;</span><span class="p">)</span></pre></div>
</div>
<p>The above statement would produce SQL like:</p>
<div class="highlight-python"><pre>SELECT id, name FROM user</pre>
</div>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> is the immediate superclass of the schema-specific
<a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> object.  While the <a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> class has all the
same capabilities as <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a>, the <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a>
class is usable by itself in those cases where behavioral requirements
are limited to simple SQL expression generation.  The object has none of
the associations with schema-level metadata or with execution-time
behavior that <a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> does, so in that sense is a &#8220;lightweight&#8221;
version of <a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a>.</p>
<p>Full details on <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> usage is at <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a>.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a></p>
<p class="last"><a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a></p>
</div>
<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnClause.__init__">
<tt class="descname">__init__</tt><big>(</big><em>text</em>, <em>type_=None</em>, <em>is_literal=False</em>, <em>_selectable=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnClause.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> object.</p>
<p>This constructor is mirrored as a public API function; see <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> for a full usage and argument description.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.ColumnCollection">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">ColumnCollection</tt><big>(</big><em>*columns</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnCollection" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.util._collections.OrderedProperties</span></tt></p>
<p>An ordered dictionary that stores a list of ColumnElement
instances.</p>
<p>Overrides the <tt class="docutils literal"><span class="pre">__eq__()</span></tt> method to produce SQL clauses between
sets of correlated columns.</p>
<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnCollection.add">
<tt class="descname">add</tt><big>(</big><em>column</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnCollection.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a column to this collection.</p>
<p>The key attribute of the column will be used as the hash key
for this dictionary.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnCollection.replace">
<tt class="descname">replace</tt><big>(</big><em>column</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnCollection.replace" title="Permalink to this definition">¶</a></dt>
<dd><p>add the given column to this collection, removing unaliased
versions of this column  as well as existing columns with the
same key.</p>
<blockquote>
<div><p>e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">t</span> <span class="o">=</span> <span class="n">Table</span><span class="p">(</span><span class="s">&#39;sometable&#39;</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">&#39;col1&#39;</span><span class="p">,</span> <span class="n">Integer</span><span class="p">))</span>
<span class="n">t</span><span class="o">.</span><span class="n">columns</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">Column</span><span class="p">(</span><span class="s">&#39;col1&#39;</span><span class="p">,</span> <span class="n">Integer</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s">&#39;columnone&#39;</span><span class="p">))</span></pre></div>
</div>
<p>will remove the original &#8216;col1&#8217; from the collection, and add
the new column under the name &#8216;columnname&#8217;.</p>
</div></blockquote>
<p>Used by schema.Column to override columns during table reflection.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.ColumnElement">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">ColumnElement</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.operators.ColumnOperators</span></tt></a>, <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ClauseElement</span></tt></a></p>
<p>Represent a column-oriented SQL expression suitable for usage in the
&#8220;columns&#8221; clause, WHERE clause etc. of a statement.</p>
<p>While the most familiar kind of <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> is the
<a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> object, <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> serves as the basis
for any unit that may be present in a SQL expression, including
the expressions themselves, SQL functions, bound parameters,
literal expressions, keywords such as <tt class="docutils literal"><span class="pre">NULL</span></tt>, etc.
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> is the ultimate base class for all such elements.</p>
<p>A wide variety of SQLAlchemy Core functions work at the SQL expression
level, and are intended to accept instances of <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> as
arguments.  These functions will typically document that they accept a
&#8220;SQL expression&#8221; as an argument.  What this means in terms of SQLAlchemy
usually refers to an input which is either already in the form of a
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> object, or a value which can be <strong>coerced</strong> into
one.  The coercion rules followed by most, but not all, SQLAlchemy Core
functions with regards to SQL expressions are as follows:</p>
<blockquote>
<div><ul class="simple">
<li>a literal Python value, such as a string, integer or floating
point value, boolean, datetime, <tt class="docutils literal"><span class="pre">Decimal</span></tt> object, or virtually
any other Python object, will be coerced into a &#8220;literal bound
value&#8221;.  This generally means that a <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> will be
produced featuring the given value embedded into the construct; the
resulting <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> object is an instance of
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>.  The Python value will ultimately be sent
to the DBAPI at execution time as a paramterized argument to the
<tt class="docutils literal"><span class="pre">execute()</span></tt> or <tt class="docutils literal"><span class="pre">executemany()</span></tt> methods, after SQLAlchemy
type-specific converters (e.g. those provided by any associated
<a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine" title="sqlalchemy.types.TypeEngine"><tt class="xref py py-class docutils literal"><span class="pre">TypeEngine</span></tt></a> objects) are applied to the value.</li>
<li>any special object value, typically ORM-level constructs, which
feature a method called <tt class="docutils literal"><span class="pre">__clause_element__()</span></tt>.  The Core
expression system looks for this method when an object of otherwise
unknown type is passed to a function that is looking to coerce the
argument into a <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> expression.  The
<tt class="docutils literal"><span class="pre">__clause_element__()</span></tt> method, if present, should return a
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> instance.  The primary use of
<tt class="docutils literal"><span class="pre">__clause_element__()</span></tt> within SQLAlchemy is that of class-bound
attributes on ORM-mapped classes; a <tt class="docutils literal"><span class="pre">User</span></tt> class which contains a
mapped attribute named <tt class="docutils literal"><span class="pre">.name</span></tt> will have a method
<tt class="docutils literal"><span class="pre">User.name.__clause_element__()</span></tt> which when invoked returns the
<a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a> called <tt class="docutils literal"><span class="pre">name</span></tt> associated with the mapped table.</li>
<li>The Python <tt class="docutils literal"><span class="pre">None</span></tt> value is typically interpreted as <tt class="docutils literal"><span class="pre">NULL</span></tt>,
which in SQLAlchemy Core produces an instance of <a class="reference internal" href="#sqlalchemy.sql.expression.null" title="sqlalchemy.sql.expression.null"><tt class="xref py py-func docutils literal"><span class="pre">null()</span></tt></a>.</li>
</ul>
</div></blockquote>
<p>A <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> provides the ability to generate new
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>
objects using Python expressions.  This means that Python operators
such as <tt class="docutils literal"><span class="pre">==</span></tt>, <tt class="docutils literal"><span class="pre">!=</span></tt> and <tt class="docutils literal"><span class="pre">&lt;</span></tt> are overloaded to mimic SQL operations,
and allow the instantiation of further <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> instances
which are composed from other, more fundamental <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>
objects.  For example, two <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> objects can be added
together with the addition operator <tt class="docutils literal"><span class="pre">+</span></tt> to produce
a <a class="reference internal" href="#sqlalchemy.sql.expression.BinaryExpression" title="sqlalchemy.sql.expression.BinaryExpression"><tt class="xref py py-class docutils literal"><span class="pre">BinaryExpression</span></tt></a>.
Both <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnClause" title="sqlalchemy.sql.expression.ColumnClause"><tt class="xref py py-class docutils literal"><span class="pre">ColumnClause</span></tt></a> and <a class="reference internal" href="#sqlalchemy.sql.expression.BinaryExpression" title="sqlalchemy.sql.expression.BinaryExpression"><tt class="xref py py-class docutils literal"><span class="pre">BinaryExpression</span></tt></a> are subclasses
of <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">column</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">column</span><span class="p">(</span><span class="s">&#39;a&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;b&#39;</span><span class="p">)</span>
<span class="go">&lt;sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;a&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;b&#39;</span><span class="p">)</span>
<span class="go">a + b</span></pre></div>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a></p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">expression.column()</span></tt></a></p>
</div>
<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.__eq__">
<tt class="descname">__eq__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.__eq__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__eq__" title="sqlalchemy.sql.operators.ColumnOperators.__eq__"><tt class="xref py py-meth docutils literal"><span class="pre">__eq__()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">==</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">=</span> <span class="pre">b</span></tt>.
If the target is <tt class="docutils literal"><span class="pre">None</span></tt>, produces <tt class="docutils literal"><span class="pre">a</span> <span class="pre">IS</span> <span class="pre">NULL</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.__init__">
<tt class="descname">__init__</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.__init__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-attr docutils literal"><span class="pre">__init__</span></tt> <em>attribute of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>x.__init__(...) initializes x; see help(type(x)) for signature</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.__le__">
<tt class="descname">__le__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.__le__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__le__" title="sqlalchemy.sql.operators.ColumnOperators.__le__"><tt class="xref py py-meth docutils literal"><span class="pre">__le__()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">&lt;=</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">&lt;=</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.__lt__">
<tt class="descname">__lt__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.__lt__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__lt__" title="sqlalchemy.sql.operators.ColumnOperators.__lt__"><tt class="xref py py-meth docutils literal"><span class="pre">__lt__()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">&lt;</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">&lt;</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.__ne__">
<tt class="descname">__ne__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.__ne__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__ne__" title="sqlalchemy.sql.operators.ColumnOperators.__ne__"><tt class="xref py py-meth docutils literal"><span class="pre">__ne__()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">!=</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">!=</span> <span class="pre">b</span></tt>.
If the target is <tt class="docutils literal"><span class="pre">None</span></tt>, produces <tt class="docutils literal"><span class="pre">a</span> <span class="pre">IS</span> <span class="pre">NOT</span> <span class="pre">NULL</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.anon_label">
<tt class="descname">anon_label</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.anon_label" title="Permalink to this definition">¶</a></dt>
<dd><p>provides a constant &#8216;anonymous label&#8217; for this ColumnElement.</p>
<p>This is a label() expression which will be named at compile time.
The same label() is returned each time anon_label is called so
that expressions can reference anon_label multiple times, producing
the same label name at compile time.</p>
<p>the compiler uses this function automatically at compile time
for expressions that are known to be &#8216;unnamed&#8217; like binary
expressions and function calls.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.asc">
<tt class="descname">asc</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.asc" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.asc" title="sqlalchemy.sql.operators.ColumnOperators.asc"><tt class="xref py py-meth docutils literal"><span class="pre">asc()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.base_columns">
<tt class="descname">base_columns</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.base_columns" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.between">
<tt class="descname">between</tt><big>(</big><em>cleft</em>, <em>cright</em>, <em>symmetric=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.between" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.between" title="sqlalchemy.sql.operators.ColumnOperators.between"><tt class="xref py py-meth docutils literal"><span class="pre">between()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.between" title="sqlalchemy.sql.expression.between"><tt class="xref py py-func docutils literal"><span class="pre">between()</span></tt></a> clause against
the parent object, given the lower and upper range.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.bind">
<tt class="descname">bind</tt><em class="property"> = None</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.bind" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.collate">
<tt class="descname">collate</tt><big>(</big><em>collation</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.collate" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.collate" title="sqlalchemy.sql.operators.ColumnOperators.collate"><tt class="xref py py-meth docutils literal"><span class="pre">collate()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.collate" title="sqlalchemy.sql.expression.collate"><tt class="xref py py-func docutils literal"><span class="pre">collate()</span></tt></a> clause against
the parent object, given the collation string.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.comparator">
<tt class="descname">comparator</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.comparator" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.compare">
<tt class="descname">compare</tt><big>(</big><em>other</em>, <em>use_proxies=False</em>, <em>equivalents=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.compare" title="Permalink to this definition">¶</a></dt>
<dd><p>Compare this ColumnElement to another.</p>
<p>Special arguments understood:</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.sql.expression.ColumnElement.compare.params.use_proxies"></span><strong>use_proxies</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.compare.params.use_proxies">¶</a> &#8211; when True, consider two columns that
share a common base column as equivalent (i.e. shares_lineage())</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.compare.params.equivalents"></span><strong>equivalents</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.compare.params.equivalents">¶</a> &#8211; a dictionary of columns as keys mapped to sets
of columns. If the given &#8220;other&#8221; column is present in this
dictionary, if any of the columns in the corresponding set() pass
the comparison test, the result is True. This is used to expand the
comparison to other columns that may be known to be equivalent to
this one via foreign key or other criterion.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.compile">
<tt class="descname">compile</tt><big>(</big><em>bind=None</em>, <em>dialect=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.compile" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement.compile" title="sqlalchemy.sql.expression.ClauseElement.compile"><tt class="xref py py-meth docutils literal"><span class="pre">compile()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a></div>
<p>Compile this SQL expression.</p>
<p>The return value is a <a class="reference internal" href="internals.html#sqlalchemy.engine.interfaces.Compiled" title="sqlalchemy.engine.interfaces.Compiled"><tt class="xref py py-class docutils literal"><span class="pre">Compiled</span></tt></a> object.
Calling <tt class="docutils literal"><span class="pre">str()</span></tt> or <tt class="docutils literal"><span class="pre">unicode()</span></tt> on the returned value will yield a
string representation of the result. The
<a class="reference internal" href="internals.html#sqlalchemy.engine.interfaces.Compiled" title="sqlalchemy.engine.interfaces.Compiled"><tt class="xref py py-class docutils literal"><span class="pre">Compiled</span></tt></a> object also can return a
dictionary of bind parameter names and values
using the <tt class="docutils literal"><span class="pre">params</span></tt> accessor.</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.sql.expression.ColumnElement.compile.params.bind"></span><strong>bind</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.compile.params.bind">¶</a> &#8211; An <tt class="docutils literal"><span class="pre">Engine</span></tt> or <tt class="docutils literal"><span class="pre">Connection</span></tt> from which a
<tt class="docutils literal"><span class="pre">Compiled</span></tt> will be acquired. This argument takes precedence over
this <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>&#8216;s bound engine, if any.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.compile.params.column_keys"></span><strong>column_keys</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.compile.params.column_keys">¶</a> &#8211; Used for INSERT and UPDATE statements, a list of
column names which should be present in the VALUES clause of the
compiled statement. If <tt class="docutils literal"><span class="pre">None</span></tt>, all columns from the target table
object are rendered.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.compile.params.dialect"></span><strong>dialect</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.compile.params.dialect">¶</a> &#8211; A <tt class="docutils literal"><span class="pre">Dialect</span></tt> instance from which a <tt class="docutils literal"><span class="pre">Compiled</span></tt>
will be acquired. This argument takes precedence over the <cite>bind</cite>
argument as well as this <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>&#8216;s bound engine,
if any.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.compile.params.inline"></span><strong>inline</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.compile.params.inline">¶</a> &#8211; Used for INSERT statements, for a dialect which does
not support inline retrieval of newly generated primary key
columns, will force the expression used to create the new primary
key value to be rendered inline within the INSERT statement&#8217;s
VALUES clause. This typically refers to Sequence execution but may
also refer to any server-side default generation function
associated with a primary key <cite>Column</cite>.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.compile.params.compile_kwargs"></span><strong>compile_kwargs</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.compile.params.compile_kwargs">¶</a> &#8211; <p>optional dictionary of additional parameters
that will be passed through to the compiler within all &#8220;visit&#8221;
methods.  This allows any custom flag to be passed through to
a custom compilation construct, for example.  It is also used
for the case of passing the <tt class="docutils literal"><span class="pre">literal_binds</span></tt> flag through:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">table</span><span class="p">,</span> <span class="n">column</span><span class="p">,</span> <span class="n">select</span>

<span class="n">t</span> <span class="o">=</span> <span class="n">table</span><span class="p">(</span><span class="s">&#39;t&#39;</span><span class="p">,</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;x&#39;</span><span class="p">))</span>

<span class="n">s</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">t</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">x</span> <span class="o">==</span> <span class="mi">5</span><span class="p">)</span>

<span class="k">print</span> <span class="n">s</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">compile_kwargs</span><span class="o">=</span><span class="p">{</span><span class="s">&quot;literal_binds&quot;</span><span class="p">:</span> <span class="bp">True</span><span class="p">})</span></pre></div>
</div>
<div class="versionadded">
<p><span>New in version 0.9.0.</span></p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="../faq.html#faq-sql-expression-string"><em>How do I render SQL expressions as strings, possibly with bound parameters inlined?</em></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.concat">
<tt class="descname">concat</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.concat" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.concat" title="sqlalchemy.sql.operators.ColumnOperators.concat"><tt class="xref py py-meth docutils literal"><span class="pre">concat()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the &#8216;concat&#8217; operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">||</span> <span class="pre">b</span></tt>,
or uses the <tt class="docutils literal"><span class="pre">concat()</span></tt> operator on MySQL.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.contains">
<tt class="descname">contains</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.contains" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.contains" title="sqlalchemy.sql.operators.ColumnOperators.contains"><tt class="xref py py-meth docutils literal"><span class="pre">contains()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the &#8216;contains&#8217; operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">LIKE</span> <span class="pre">'%&lt;other&gt;%'</span></tt></p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.desc">
<tt class="descname">desc</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.desc" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.desc" title="sqlalchemy.sql.operators.ColumnOperators.desc"><tt class="xref py py-meth docutils literal"><span class="pre">desc()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.description">
<tt class="descname">description</tt><em class="property"> = None</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.description" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.distinct">
<tt class="descname">distinct</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.distinct" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.distinct" title="sqlalchemy.sql.operators.ColumnOperators.distinct"><tt class="xref py py-meth docutils literal"><span class="pre">distinct()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.distinct" title="sqlalchemy.sql.expression.distinct"><tt class="xref py py-func docutils literal"><span class="pre">distinct()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.endswith">
<tt class="descname">endswith</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.endswith" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.endswith" title="sqlalchemy.sql.operators.ColumnOperators.endswith"><tt class="xref py py-meth docutils literal"><span class="pre">endswith()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the &#8216;endswith&#8217; operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">LIKE</span> <span class="pre">'%&lt;other&gt;'</span></tt></p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.expression">
<tt class="descname">expression</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.expression" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a column expression.</p>
<p>Part of the inspection interface; returns self.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.foreign_keys">
<tt class="descname">foreign_keys</tt><em class="property"> = []</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.foreign_keys" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.get_children">
<tt class="descname">get_children</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.get_children" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement.get_children" title="sqlalchemy.sql.expression.ClauseElement.get_children"><tt class="xref py py-meth docutils literal"><span class="pre">get_children()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a></div>
<p>Return immediate child elements of this <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>.</p>
<p>This is used for visit traversal.</p>
<p>**kwargs may contain flags that change the collection that is
returned, for example to return a subset of items in order to
cut down on larger traversals, or to return child items from a
different context (such as schema-level collections instead of
clause-level).</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.ilike">
<tt class="descname">ilike</tt><big>(</big><em>other</em>, <em>escape=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.ilike" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike" title="sqlalchemy.sql.operators.ColumnOperators.ilike"><tt class="xref py py-meth docutils literal"><span class="pre">ilike()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">ilike</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">ILIKE</span> <span class="pre">other</span></tt>.</p>
<p>E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">select</span><span class="p">([</span><span class="n">sometable</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">sometable</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">column</span><span class="o">.</span><span class="n">ilike</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%f</span><span class="s">oobar%&quot;</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.sql.expression.ColumnElement.ilike.params.other"></span><strong>other</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.ilike.params.other">¶</a> &#8211; expression to be compared</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.ilike.params.escape"></span><strong>escape</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.ilike.params.escape">¶</a> &#8211; <p>optional escape character, renders the <tt class="docutils literal"><span class="pre">ESCAPE</span></tt>
keyword, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">ilike</span><span class="p">(</span><span class="s">&quot;foo/%bar&quot;</span><span class="p">,</span> <span class="n">escape</span><span class="o">=</span><span class="s">&quot;/&quot;</span><span class="p">)</span></pre></div>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like" title="sqlalchemy.sql.operators.ColumnOperators.like"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.like()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.in_">
<tt class="descname">in_</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.in_" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.in_" title="sqlalchemy.sql.operators.ColumnOperators.in_"><tt class="xref py py-meth docutils literal"><span class="pre">in_()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">in</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">IN</span> <span class="pre">other</span></tt>.
&#8220;other&#8221; may be a tuple/list of column expressions,
or a <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.select" title="sqlalchemy.sql.expression.select"><tt class="xref py py-func docutils literal"><span class="pre">select()</span></tt></a> construct.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.is_">
<tt class="descname">is_</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.is_" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.is_" title="sqlalchemy.sql.operators.ColumnOperators.is_"><tt class="xref py py-meth docutils literal"><span class="pre">is_()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">IS</span></tt> operator.</p>
<p>Normally, <tt class="docutils literal"><span class="pre">IS</span></tt> is generated automatically when comparing to a
value of <tt class="docutils literal"><span class="pre">None</span></tt>, which resolves to <tt class="docutils literal"><span class="pre">NULL</span></tt>.  However, explicit
usage of <tt class="docutils literal"><span class="pre">IS</span></tt> may be desirable if comparing to boolean values
on certain platforms.</p>
<div class="versionadded">
<p><span>New in version 0.7.9.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.isnot" title="sqlalchemy.sql.operators.ColumnOperators.isnot"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.isnot()</span></tt></a></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.is_clause_element">
<tt class="descname">is_clause_element</tt><em class="property"> = True</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.is_clause_element" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.is_selectable">
<tt class="descname">is_selectable</tt><em class="property"> = False</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.is_selectable" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.isnot">
<tt class="descname">isnot</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.isnot" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.isnot" title="sqlalchemy.sql.operators.ColumnOperators.isnot"><tt class="xref py py-meth docutils literal"><span class="pre">isnot()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">IS</span> <span class="pre">NOT</span></tt> operator.</p>
<p>Normally, <tt class="docutils literal"><span class="pre">IS</span> <span class="pre">NOT</span></tt> is generated automatically when comparing to a
value of <tt class="docutils literal"><span class="pre">None</span></tt>, which resolves to <tt class="docutils literal"><span class="pre">NULL</span></tt>.  However, explicit
usage of <tt class="docutils literal"><span class="pre">IS</span> <span class="pre">NOT</span></tt> may be desirable if comparing to boolean values
on certain platforms.</p>
<div class="versionadded">
<p><span>New in version 0.7.9.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.is_" title="sqlalchemy.sql.operators.ColumnOperators.is_"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.is_()</span></tt></a></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.key">
<tt class="descname">key</tt><em class="property"> = None</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.key" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.label">
<tt class="descname">label</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.label" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a column label, i.e. <tt class="docutils literal"><span class="pre">&lt;columnname&gt;</span> <span class="pre">AS</span> <span class="pre">&lt;name&gt;</span></tt>.</p>
<p>This is a shortcut to the <a class="reference internal" href="#sqlalchemy.sql.expression.label" title="sqlalchemy.sql.expression.label"><tt class="xref py py-func docutils literal"><span class="pre">label()</span></tt></a> function.</p>
<p>if &#8216;name&#8217; is None, an anonymous label name will be generated.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.like">
<tt class="descname">like</tt><big>(</big><em>other</em>, <em>escape=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.like" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like" title="sqlalchemy.sql.operators.ColumnOperators.like"><tt class="xref py py-meth docutils literal"><span class="pre">like()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">like</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">LIKE</span> <span class="pre">other</span></tt>.</p>
<p>E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">select</span><span class="p">([</span><span class="n">sometable</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">sometable</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">column</span><span class="o">.</span><span class="n">like</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%f</span><span class="s">oobar%&quot;</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.sql.expression.ColumnElement.like.params.other"></span><strong>other</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.like.params.other">¶</a> &#8211; expression to be compared</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.like.params.escape"></span><strong>escape</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.like.params.escape">¶</a> &#8211; <p>optional escape character, renders the <tt class="docutils literal"><span class="pre">ESCAPE</span></tt>
keyword, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">like</span><span class="p">(</span><span class="s">&quot;foo/%bar&quot;</span><span class="p">,</span> <span class="n">escape</span><span class="o">=</span><span class="s">&quot;/&quot;</span><span class="p">)</span></pre></div>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike" title="sqlalchemy.sql.operators.ColumnOperators.ilike"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.ilike()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.match">
<tt class="descname">match</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.match" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.match" title="sqlalchemy.sql.operators.ColumnOperators.match"><tt class="xref py py-meth docutils literal"><span class="pre">match()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implements a database-specific &#8216;match&#8217; operator.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.match" title="sqlalchemy.sql.operators.ColumnOperators.match"><tt class="xref py py-meth docutils literal"><span class="pre">match()</span></tt></a> attempts to resolve to
a MATCH-like function or operator provided by the backend.
Examples include:</p>
<ul class="simple">
<li>Postgresql - renders <tt class="docutils literal"><span class="pre">x</span> <span class="pre">&#64;&#64;</span> <span class="pre">to_tsquery(y)</span></tt></li>
<li>MySQL - renders <tt class="docutils literal"><span class="pre">MATCH</span> <span class="pre">(x)</span> <span class="pre">AGAINST</span> <span class="pre">(y</span> <span class="pre">IN</span> <span class="pre">BOOLEAN</span> <span class="pre">MODE)</span></tt></li>
<li>Oracle - renders <tt class="docutils literal"><span class="pre">CONTAINS(x,</span> <span class="pre">y)</span></tt></li>
<li>other backends may provide special implementations;
some backends such as SQLite have no support.</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.notilike">
<tt class="descname">notilike</tt><big>(</big><em>other</em>, <em>escape=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.notilike" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.notilike" title="sqlalchemy.sql.operators.ColumnOperators.notilike"><tt class="xref py py-meth docutils literal"><span class="pre">notilike()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>implement the <tt class="docutils literal"><span class="pre">NOT</span> <span class="pre">ILIKE</span></tt> operator.</p>
<p>This is equivalent to using negation with
<a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike" title="sqlalchemy.sql.operators.ColumnOperators.ilike"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.ilike()</span></tt></a>, i.e. <tt class="docutils literal"><span class="pre">~x.ilike(y)</span></tt>.</p>
<div class="versionadded">
<p><span>New in version 0.8.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike" title="sqlalchemy.sql.operators.ColumnOperators.ilike"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.ilike()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.notin_">
<tt class="descname">notin_</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.notin_" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.notin_" title="sqlalchemy.sql.operators.ColumnOperators.notin_"><tt class="xref py py-meth docutils literal"><span class="pre">notin_()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>implement the <tt class="docutils literal"><span class="pre">NOT</span> <span class="pre">IN</span></tt> operator.</p>
<p>This is equivalent to using negation with
<a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.in_" title="sqlalchemy.sql.operators.ColumnOperators.in_"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.in_()</span></tt></a>, i.e. <tt class="docutils literal"><span class="pre">~x.in_(y)</span></tt>.</p>
<div class="versionadded">
<p><span>New in version 0.8.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.in_" title="sqlalchemy.sql.operators.ColumnOperators.in_"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.in_()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.notlike">
<tt class="descname">notlike</tt><big>(</big><em>other</em>, <em>escape=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.notlike" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.notlike" title="sqlalchemy.sql.operators.ColumnOperators.notlike"><tt class="xref py py-meth docutils literal"><span class="pre">notlike()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>implement the <tt class="docutils literal"><span class="pre">NOT</span> <span class="pre">LIKE</span></tt> operator.</p>
<p>This is equivalent to using negation with
<a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like" title="sqlalchemy.sql.operators.ColumnOperators.like"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.like()</span></tt></a>, i.e. <tt class="docutils literal"><span class="pre">~x.like(y)</span></tt>.</p>
<div class="versionadded">
<p><span>New in version 0.8.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like" title="sqlalchemy.sql.operators.ColumnOperators.like"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.like()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.nullsfirst">
<tt class="descname">nullsfirst</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.nullsfirst" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.nullsfirst" title="sqlalchemy.sql.operators.ColumnOperators.nullsfirst"><tt class="xref py py-meth docutils literal"><span class="pre">nullsfirst()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.nullsfirst" title="sqlalchemy.sql.expression.nullsfirst"><tt class="xref py py-func docutils literal"><span class="pre">nullsfirst()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.nullslast">
<tt class="descname">nullslast</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.nullslast" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.nullslast" title="sqlalchemy.sql.operators.ColumnOperators.nullslast"><tt class="xref py py-meth docutils literal"><span class="pre">nullslast()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.nullslast" title="sqlalchemy.sql.expression.nullslast"><tt class="xref py py-func docutils literal"><span class="pre">nullslast()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.op">
<tt class="descname">op</tt><big>(</big><em>opstring</em>, <em>precedence=0</em>, <em>is_comparison=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.op" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.op" title="sqlalchemy.sql.operators.Operators.op"><tt class="xref py py-meth docutils literal"><span class="pre">op()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">Operators</span></tt></a></div>
<p>produce a generic operator function.</p>
<p>e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">op</span><span class="p">(</span><span class="s">&quot;*&quot;</span><span class="p">)(</span><span class="mi">5</span><span class="p">)</span></pre></div>
</div>
<p>produces:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span> <span class="o">*</span> <span class="mi">5</span></pre></div>
</div>
<p>This function can also be used to make bitwise operators explicit. For
example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">op</span><span class="p">(</span><span class="s">&#39;&amp;&#39;</span><span class="p">)(</span><span class="mh">0xff</span><span class="p">)</span></pre></div>
</div>
<p>is a bitwise AND of the value in <tt class="docutils literal"><span class="pre">somecolumn</span></tt>.</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.sql.expression.ColumnElement.op.params.operator"></span><strong>operator</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.op.params.operator">¶</a> &#8211; a string which will be output as the infix operator
between this element and the expression passed to the
generated function.</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.op.params.precedence"></span><strong>precedence</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.op.params.precedence">¶</a> &#8211; <p>precedence to apply to the operator, when
parenthesizing expressions.  A lower number will cause the expression
to be parenthesized when applied against another operator with
higher precedence.  The default value of <tt class="docutils literal"><span class="pre">0</span></tt> is lower than all
operators except for the comma (<tt class="docutils literal"><span class="pre">,</span></tt>) and <tt class="docutils literal"><span class="pre">AS</span></tt> operators.
A value of 100 will be higher or equal to all operators, and -100
will be lower than or equal to all operators.</p>
<div class="versionadded">
<p><span>New in version 0.8: </span>- added the &#8216;precedence&#8217; argument.</p>
</div>
</li>
<li><span class="target" id="sqlalchemy.sql.expression.ColumnElement.op.params.is_comparison"></span><strong>is_comparison</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.expression.ColumnElement.op.params.is_comparison">¶</a> &#8211; <p>if True, the operator will be considered as a
&#8220;comparison&#8221; operator, that is which evaulates to a boolean
true/false value, like <tt class="docutils literal"><span class="pre">==</span></tt>, <tt class="docutils literal"><span class="pre">&gt;</span></tt>, etc.  This flag should be set
so that ORM relationships can establish that the operator is a
comparison operator when used in a custom join condition.</p>
<div class="versionadded">
<p><span>New in version 0.9.2: </span>- added the
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.op.params.is_comparison" title="sqlalchemy.sql.operators.Operators.op"><tt class="xref py py-paramref docutils literal"><span class="pre">Operators.op.is_comparison</span></tt></a> flag.</p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="types.html#types-operators"><em>Redefining and Creating New Operators</em></a></p>
<p class="last"><a class="reference internal" href="../orm/relationships.html#relationship-custom-operator"><em>Using custom operators in join conditions</em></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.operate">
<tt class="descname">operate</tt><big>(</big><em>op</em>, <em>*other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.operate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.params">
<tt class="descname">params</tt><big>(</big><em>*optionaldict</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.params" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement.params" title="sqlalchemy.sql.expression.ClauseElement.params"><tt class="xref py py-meth docutils literal"><span class="pre">params()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a></div>
<p>Return a copy with <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> elements replaced.</p>
<p>Returns a copy of this ClauseElement with <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a>
elements replaced with values taken from the given dictionary:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">clause</span> <span class="o">=</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;x&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">clause</span><span class="o">.</span><span class="n">compile</span><span class="p">()</span><span class="o">.</span><span class="n">params</span>
<span class="go">{&#39;foo&#39;:None}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">clause</span><span class="o">.</span><span class="n">params</span><span class="p">({</span><span class="s">&#39;foo&#39;</span><span class="p">:</span><span class="mi">7</span><span class="p">})</span><span class="o">.</span><span class="n">compile</span><span class="p">()</span><span class="o">.</span><span class="n">params</span>
<span class="go">{&#39;foo&#39;:7}</span></pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.primary_key">
<tt class="descname">primary_key</tt><em class="property"> = False</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.primary_key" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.proxy_set">
<tt class="descname">proxy_set</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.proxy_set" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.reverse_operate">
<tt class="descname">reverse_operate</tt><big>(</big><em>op</em>, <em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.reverse_operate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.self_group">
<tt class="descname">self_group</tt><big>(</big><em>against=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.self_group" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.shares_lineage">
<tt class="descname">shares_lineage</tt><big>(</big><em>othercolumn</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.shares_lineage" title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the given <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>
has a common ancestor to this <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.startswith">
<tt class="descname">startswith</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.startswith" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.startswith" title="sqlalchemy.sql.operators.ColumnOperators.startswith"><tt class="xref py py-meth docutils literal"><span class="pre">startswith()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">startwith</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">LIKE</span> <span class="pre">'&lt;other&gt;%'</span></tt></p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.supports_execution">
<tt class="descname">supports_execution</tt><em class="property"> = False</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.supports_execution" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.timetuple">
<tt class="descname">timetuple</tt><em class="property"> = None</em><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.timetuple" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.expression.ColumnElement.type">
<tt class="descname">type</tt><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.type" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.ColumnElement.unique_params">
<tt class="descname">unique_params</tt><big>(</big><em>*optionaldict</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.ColumnElement.unique_params" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement.unique_params" title="sqlalchemy.sql.expression.ClauseElement.unique_params"><tt class="xref py py-meth docutils literal"><span class="pre">unique_params()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a></div>
<p>Return a copy with <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> elements replaced.</p>
<p>Same functionality as <tt class="docutils literal"><span class="pre">params()</span></tt>, except adds <cite>unique=True</cite>
to affected bind parameters so that multiple statements can be
used.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.operators.ColumnOperators">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.operators.</tt><tt class="descname">ColumnOperators</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.operators.Operators</span></tt></a></p>
<p>Defines boolean, comparison, and other operators for
<a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> expressions.</p>
<p>By default, all methods call down to
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.operate" title="sqlalchemy.sql.operators.Operators.operate"><tt class="xref py py-meth docutils literal"><span class="pre">operate()</span></tt></a> or <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement.reverse_operate" title="sqlalchemy.sql.expression.ColumnElement.reverse_operate"><tt class="xref py py-meth docutils literal"><span class="pre">reverse_operate()</span></tt></a>,
passing in the appropriate operator function from the
Python builtin <tt class="docutils literal"><span class="pre">operator</span></tt> module or
a SQLAlchemy-specific operator function from
<tt class="xref py py-mod docutils literal"><span class="pre">sqlalchemy.expression.operators</span></tt>.   For example
the <tt class="docutils literal"><span class="pre">__eq__</span></tt> function:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">operate</span><span class="p">(</span><span class="n">operators</span><span class="o">.</span><span class="n">eq</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span></pre></div>
</div>
<p>Where <tt class="docutils literal"><span class="pre">operators.eq</span></tt> is essentially:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">eq</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">a</span> <span class="o">==</span> <span class="n">b</span></pre></div>
</div>
<p>The core column expression unit <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a>
overrides <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.operate" title="sqlalchemy.sql.operators.Operators.operate"><tt class="xref py py-meth docutils literal"><span class="pre">Operators.operate()</span></tt></a> and others
to return further <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">ColumnElement</span></tt></a> constructs,
so that the <tt class="docutils literal"><span class="pre">==</span></tt> operation above is replaced by a clause
construct.</p>
<p>See also:</p>
<p><a class="reference internal" href="types.html#types-operators"><em>Redefining and Creating New Operators</em></a></p>
<p><a class="reference internal" href="types.html#sqlalchemy.types.TypeEngine.comparator_factory" title="sqlalchemy.types.TypeEngine.comparator_factory"><tt class="xref py py-attr docutils literal"><span class="pre">TypeEngine.comparator_factory</span></tt></a></p>
<p><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a></p>
<p><a class="reference internal" href="../orm/internals.html#sqlalchemy.orm.interfaces.PropComparator" title="sqlalchemy.orm.interfaces.PropComparator"><tt class="xref py py-class docutils literal"><span class="pre">PropComparator</span></tt></a></p>
<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__add__">
<tt class="descname">__add__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__add__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">+</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">+</span> <span class="pre">b</span></tt>
if the parent object has non-string affinity.
If the parent object has a string affinity,
produces the concatenation operator, <tt class="docutils literal"><span class="pre">a</span> <span class="pre">||</span> <span class="pre">b</span></tt> -
see <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.concat" title="sqlalchemy.sql.operators.ColumnOperators.concat"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.concat()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__and__">
<tt class="descname">__and__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__and__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.__and__" title="sqlalchemy.sql.operators.Operators.__and__"><tt class="xref py py-meth docutils literal"><span class="pre">__and__()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">Operators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">&amp;</span></tt> operator.</p>
<p>When used with SQL expressions, results in an
AND operation, equivalent to
<a class="reference internal" href="#sqlalchemy.sql.expression.and_" title="sqlalchemy.sql.expression.and_"><tt class="xref py py-func docutils literal"><span class="pre">and_()</span></tt></a>, that is:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">a</span> <span class="o">&amp;</span> <span class="n">b</span></pre></div>
</div>
<p>is equivalent to:</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">and_</span>
<span class="n">and_</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span></pre></div>
</div>
<p>Care should be taken when using <tt class="docutils literal"><span class="pre">&amp;</span></tt> regarding
operator precedence; the <tt class="docutils literal"><span class="pre">&amp;</span></tt> operator has the highest precedence.
The operands should be enclosed in parenthesis if they contain
further sub expressions:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">(</span><span class="n">a</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="o">&amp;</span> <span class="p">(</span><span class="n">b</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span></pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__delattr__">
<tt class="descname">__delattr__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__delattr__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-attr docutils literal"><span class="pre">__delattr__</span></tt> <em>attribute of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>x.__delattr__(&#8216;name&#8217;) &lt;==&gt; del x.name</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__div__">
<tt class="descname">__div__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__div__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">/</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">/</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__eq__">
<tt class="descname">__eq__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__eq__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">==</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">=</span> <span class="pre">b</span></tt>.
If the target is <tt class="docutils literal"><span class="pre">None</span></tt>, produces <tt class="docutils literal"><span class="pre">a</span> <span class="pre">IS</span> <span class="pre">NULL</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__format__">
<tt class="descname">__format__</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__format__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-meth docutils literal"><span class="pre">__format__()</span></tt> <em>method of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>default object formatter</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__ge__">
<tt class="descname">__ge__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__ge__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">&gt;=</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">&gt;=</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__getattribute__">
<tt class="descname">__getattribute__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__getattribute__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-attr docutils literal"><span class="pre">__getattribute__</span></tt> <em>attribute of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>x.__getattribute__(&#8216;name&#8217;) &lt;==&gt; x.name</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__getitem__">
<tt class="descname">__getitem__</tt><big>(</big><em>index</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__getitem__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the [] operator.</p>
<p>This can be used by some database-specific types
such as Postgresql ARRAY and HSTORE.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__gt__">
<tt class="descname">__gt__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__gt__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">&gt;</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">&gt;</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__hash__">
<tt class="descname">__hash__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__hash__" title="Permalink to this definition">¶</a></dt>
<dd><p>x.__hash__() &lt;==&gt; hash(x)</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__init__">
<tt class="descname">__init__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__init__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-attr docutils literal"><span class="pre">__init__</span></tt> <em>attribute of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>x.__init__(...) initializes x; see help(type(x)) for signature</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__invert__">
<tt class="descname">__invert__</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__invert__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.__invert__" title="sqlalchemy.sql.operators.Operators.__invert__"><tt class="xref py py-meth docutils literal"><span class="pre">__invert__()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">Operators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">~</span></tt> operator.</p>
<p>When used with SQL expressions, results in a
NOT operation, equivalent to
<a class="reference internal" href="#sqlalchemy.sql.expression.not_" title="sqlalchemy.sql.expression.not_"><tt class="xref py py-func docutils literal"><span class="pre">not_()</span></tt></a>, that is:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="o">~</span><span class="n">a</span></pre></div>
</div>
<p>is equivalent to:</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">not_</span>
<span class="n">not_</span><span class="p">(</span><span class="n">a</span><span class="p">)</span></pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__le__">
<tt class="descname">__le__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__le__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">&lt;=</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">&lt;=</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__lshift__">
<tt class="descname">__lshift__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__lshift__" title="Permalink to this definition">¶</a></dt>
<dd><p>implement the &lt;&lt; operator.</p>
<p>Not used by SQLAlchemy core, this is provided
for custom operator systems which want to use
&lt;&lt; as an extension point.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__lt__">
<tt class="descname">__lt__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__lt__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">&lt;</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">&lt;</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__mod__">
<tt class="descname">__mod__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__mod__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">%</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">%</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__mul__">
<tt class="descname">__mul__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__mul__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">*</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">*</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__ne__">
<tt class="descname">__ne__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__ne__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">!=</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">!=</span> <span class="pre">b</span></tt>.
If the target is <tt class="docutils literal"><span class="pre">None</span></tt>, produces <tt class="docutils literal"><span class="pre">a</span> <span class="pre">IS</span> <span class="pre">NOT</span> <span class="pre">NULL</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__neg__">
<tt class="descname">__neg__</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__neg__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">-</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">-a</span></tt>.</p>
</dd></dl>

<dl class="staticmethod">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__new__">
<em class="property">static </em><tt class="descname">__new__</tt><big>(</big><em>S</em>, <em>...</em><big>)</big> &rarr; a new object with type S, a subtype of T<a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__new__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-meth docutils literal"><span class="pre">__new__()</span></tt> <em>method of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__or__">
<tt class="descname">__or__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__or__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.__or__" title="sqlalchemy.sql.operators.Operators.__or__"><tt class="xref py py-meth docutils literal"><span class="pre">__or__()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">Operators</span></tt></a></div>
<p>Implement the <tt class="docutils literal"><span class="pre">|</span></tt> operator.</p>
<p>When used with SQL expressions, results in an
OR operation, equivalent to
<a class="reference internal" href="#sqlalchemy.sql.expression.or_" title="sqlalchemy.sql.expression.or_"><tt class="xref py py-func docutils literal"><span class="pre">or_()</span></tt></a>, that is:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">a</span> <span class="o">|</span> <span class="n">b</span></pre></div>
</div>
<p>is equivalent to:</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">or_</span>
<span class="n">or_</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span></pre></div>
</div>
<p>Care should be taken when using <tt class="docutils literal"><span class="pre">|</span></tt> regarding
operator precedence; the <tt class="docutils literal"><span class="pre">|</span></tt> operator has the highest precedence.
The operands should be enclosed in parenthesis if they contain
further sub expressions:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">(</span><span class="n">a</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span><span class="n">b</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span></pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__radd__">
<tt class="descname">__radd__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__radd__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">+</span></tt> operator in reverse.</p>
<p>See <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__add__" title="sqlalchemy.sql.operators.ColumnOperators.__add__"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.__add__()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__rdiv__">
<tt class="descname">__rdiv__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__rdiv__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">/</span></tt> operator in reverse.</p>
<p>See <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__div__" title="sqlalchemy.sql.operators.ColumnOperators.__div__"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.__div__()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__reduce__">
<tt class="descname">__reduce__</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__reduce__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-meth docutils literal"><span class="pre">__reduce__()</span></tt> <em>method of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>helper for pickle</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__reduce_ex__">
<tt class="descname">__reduce_ex__</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__reduce_ex__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-meth docutils literal"><span class="pre">__reduce_ex__()</span></tt> <em>method of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>helper for pickle</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__repr__">
<tt class="descname">__repr__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__repr__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-attr docutils literal"><span class="pre">__repr__</span></tt> <em>attribute of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>x.__repr__() &lt;==&gt; repr(x)</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__rmul__">
<tt class="descname">__rmul__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__rmul__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">*</span></tt> operator in reverse.</p>
<p>See <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__mul__" title="sqlalchemy.sql.operators.ColumnOperators.__mul__"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.__mul__()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__rshift__">
<tt class="descname">__rshift__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__rshift__" title="Permalink to this definition">¶</a></dt>
<dd><p>implement the &gt;&gt; operator.</p>
<p>Not used by SQLAlchemy core, this is provided
for custom operator systems which want to use
&gt;&gt; as an extension point.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__rsub__">
<tt class="descname">__rsub__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__rsub__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">-</span></tt> operator in reverse.</p>
<p>See <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__sub__" title="sqlalchemy.sql.operators.ColumnOperators.__sub__"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.__sub__()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__rtruediv__">
<tt class="descname">__rtruediv__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__rtruediv__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">//</span></tt> operator in reverse.</p>
<p>See <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.__truediv__" title="sqlalchemy.sql.operators.ColumnOperators.__truediv__"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.__truediv__()</span></tt></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__setattr__">
<tt class="descname">__setattr__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__setattr__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-attr docutils literal"><span class="pre">__setattr__</span></tt> <em>attribute of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>x.__setattr__(&#8216;name&#8217;, value) &lt;==&gt; x.name = value</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__sizeof__">
<tt class="descname">__sizeof__</tt><big>(</big><big>)</big> &rarr; int<a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__sizeof__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-meth docutils literal"><span class="pre">__sizeof__()</span></tt> <em>method of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>size of object in memory, in bytes</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__str__">
<tt class="descname">__str__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__str__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-attr docutils literal"><span class="pre">__str__</span></tt> <em>attribute of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>x.__str__() &lt;==&gt; str(x)</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__sub__">
<tt class="descname">__sub__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__sub__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">-</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="staticmethod">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__subclasshook__">
<em class="property">static </em><tt class="descname">__subclasshook__</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__subclasshook__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <tt class="xref py py-meth docutils literal"><span class="pre">__subclasshook__()</span></tt> <em>method of</em> <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></div>
<p>Abstract classes can override this to customize issubclass().</p>
<p>This is invoked early on by abc.ABCMeta.__subclasscheck__().
It should return True, False or NotImplemented.  If it returns
NotImplemented, the normal algorithm is used.  Otherwise, it
overrides the normal algorithm (and the outcome is cached).</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__truediv__">
<tt class="descname">__truediv__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__truediv__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">//</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">/</span> <span class="pre">b</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.__weakref__">
<tt class="descname">__weakref__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.__weakref__" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.__weakref__" title="sqlalchemy.sql.operators.Operators.__weakref__"><tt class="xref py py-attr docutils literal"><span class="pre">__weakref__</span></tt></a> <em>attribute of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">Operators</span></tt></a></div>
<p>list of weak references to the object (if defined)</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.asc">
<tt class="descname">asc</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.asc" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.between">
<tt class="descname">between</tt><big>(</big><em>cleft</em>, <em>cright</em>, <em>symmetric=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.between" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.between" title="sqlalchemy.sql.expression.between"><tt class="xref py py-func docutils literal"><span class="pre">between()</span></tt></a> clause against
the parent object, given the lower and upper range.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.collate">
<tt class="descname">collate</tt><big>(</big><em>collation</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.collate" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.collate" title="sqlalchemy.sql.expression.collate"><tt class="xref py py-func docutils literal"><span class="pre">collate()</span></tt></a> clause against
the parent object, given the collation string.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.concat">
<tt class="descname">concat</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.concat" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the &#8216;concat&#8217; operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">||</span> <span class="pre">b</span></tt>,
or uses the <tt class="docutils literal"><span class="pre">concat()</span></tt> operator on MySQL.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.contains">
<tt class="descname">contains</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the &#8216;contains&#8217; operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">LIKE</span> <span class="pre">'%&lt;other&gt;%'</span></tt></p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.desc">
<tt class="descname">desc</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.desc" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.distinct">
<tt class="descname">distinct</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.distinct" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.distinct" title="sqlalchemy.sql.expression.distinct"><tt class="xref py py-func docutils literal"><span class="pre">distinct()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.endswith">
<tt class="descname">endswith</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.endswith" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the &#8216;endswith&#8217; operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">LIKE</span> <span class="pre">'%&lt;other&gt;'</span></tt></p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.ilike">
<tt class="descname">ilike</tt><big>(</big><em>other</em>, <em>escape=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.ilike" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">ilike</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">ILIKE</span> <span class="pre">other</span></tt>.</p>
<p>E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">select</span><span class="p">([</span><span class="n">sometable</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">sometable</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">column</span><span class="o">.</span><span class="n">ilike</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%f</span><span class="s">oobar%&quot;</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.sql.operators.ColumnOperators.ilike.params.other"></span><strong>other</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike.params.other">¶</a> &#8211; expression to be compared</li>
<li><span class="target" id="sqlalchemy.sql.operators.ColumnOperators.ilike.params.escape"></span><strong>escape</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike.params.escape">¶</a> &#8211; <p>optional escape character, renders the <tt class="docutils literal"><span class="pre">ESCAPE</span></tt>
keyword, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">ilike</span><span class="p">(</span><span class="s">&quot;foo/%bar&quot;</span><span class="p">,</span> <span class="n">escape</span><span class="o">=</span><span class="s">&quot;/&quot;</span><span class="p">)</span></pre></div>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like" title="sqlalchemy.sql.operators.ColumnOperators.like"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.like()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.in_">
<tt class="descname">in_</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.in_" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">in</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">IN</span> <span class="pre">other</span></tt>.
&#8220;other&#8221; may be a tuple/list of column expressions,
or a <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.select" title="sqlalchemy.sql.expression.select"><tt class="xref py py-func docutils literal"><span class="pre">select()</span></tt></a> construct.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.is_">
<tt class="descname">is_</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.is_" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">IS</span></tt> operator.</p>
<p>Normally, <tt class="docutils literal"><span class="pre">IS</span></tt> is generated automatically when comparing to a
value of <tt class="docutils literal"><span class="pre">None</span></tt>, which resolves to <tt class="docutils literal"><span class="pre">NULL</span></tt>.  However, explicit
usage of <tt class="docutils literal"><span class="pre">IS</span></tt> may be desirable if comparing to boolean values
on certain platforms.</p>
<div class="versionadded">
<p><span>New in version 0.7.9.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.isnot" title="sqlalchemy.sql.operators.ColumnOperators.isnot"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.isnot()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.isnot">
<tt class="descname">isnot</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.isnot" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">IS</span> <span class="pre">NOT</span></tt> operator.</p>
<p>Normally, <tt class="docutils literal"><span class="pre">IS</span> <span class="pre">NOT</span></tt> is generated automatically when comparing to a
value of <tt class="docutils literal"><span class="pre">None</span></tt>, which resolves to <tt class="docutils literal"><span class="pre">NULL</span></tt>.  However, explicit
usage of <tt class="docutils literal"><span class="pre">IS</span> <span class="pre">NOT</span></tt> may be desirable if comparing to boolean values
on certain platforms.</p>
<div class="versionadded">
<p><span>New in version 0.7.9.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.is_" title="sqlalchemy.sql.operators.ColumnOperators.is_"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.is_()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.like">
<tt class="descname">like</tt><big>(</big><em>other</em>, <em>escape=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.like" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">like</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">a</span> <span class="pre">LIKE</span> <span class="pre">other</span></tt>.</p>
<p>E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">select</span><span class="p">([</span><span class="n">sometable</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">sometable</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">column</span><span class="o">.</span><span class="n">like</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%f</span><span class="s">oobar%&quot;</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.sql.operators.ColumnOperators.like.params.other"></span><strong>other</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like.params.other">¶</a> &#8211; expression to be compared</li>
<li><span class="target" id="sqlalchemy.sql.operators.ColumnOperators.like.params.escape"></span><strong>escape</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like.params.escape">¶</a> &#8211; <p>optional escape character, renders the <tt class="docutils literal"><span class="pre">ESCAPE</span></tt>
keyword, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">like</span><span class="p">(</span><span class="s">&quot;foo/%bar&quot;</span><span class="p">,</span> <span class="n">escape</span><span class="o">=</span><span class="s">&quot;/&quot;</span><span class="p">)</span></pre></div>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike" title="sqlalchemy.sql.operators.ColumnOperators.ilike"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.ilike()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.match">
<tt class="descname">match</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.match" title="Permalink to this definition">¶</a></dt>
<dd><p>Implements a database-specific &#8216;match&#8217; operator.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.match" title="sqlalchemy.sql.operators.ColumnOperators.match"><tt class="xref py py-meth docutils literal"><span class="pre">match()</span></tt></a> attempts to resolve to
a MATCH-like function or operator provided by the backend.
Examples include:</p>
<ul class="simple">
<li>Postgresql - renders <tt class="docutils literal"><span class="pre">x</span> <span class="pre">&#64;&#64;</span> <span class="pre">to_tsquery(y)</span></tt></li>
<li>MySQL - renders <tt class="docutils literal"><span class="pre">MATCH</span> <span class="pre">(x)</span> <span class="pre">AGAINST</span> <span class="pre">(y</span> <span class="pre">IN</span> <span class="pre">BOOLEAN</span> <span class="pre">MODE)</span></tt></li>
<li>Oracle - renders <tt class="docutils literal"><span class="pre">CONTAINS(x,</span> <span class="pre">y)</span></tt></li>
<li>other backends may provide special implementations;
some backends such as SQLite have no support.</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.notilike">
<tt class="descname">notilike</tt><big>(</big><em>other</em>, <em>escape=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.notilike" title="Permalink to this definition">¶</a></dt>
<dd><p>implement the <tt class="docutils literal"><span class="pre">NOT</span> <span class="pre">ILIKE</span></tt> operator.</p>
<p>This is equivalent to using negation with
<a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike" title="sqlalchemy.sql.operators.ColumnOperators.ilike"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.ilike()</span></tt></a>, i.e. <tt class="docutils literal"><span class="pre">~x.ilike(y)</span></tt>.</p>
<div class="versionadded">
<p><span>New in version 0.8.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.ilike" title="sqlalchemy.sql.operators.ColumnOperators.ilike"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.ilike()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.notin_">
<tt class="descname">notin_</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.notin_" title="Permalink to this definition">¶</a></dt>
<dd><p>implement the <tt class="docutils literal"><span class="pre">NOT</span> <span class="pre">IN</span></tt> operator.</p>
<p>This is equivalent to using negation with
<a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.in_" title="sqlalchemy.sql.operators.ColumnOperators.in_"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.in_()</span></tt></a>, i.e. <tt class="docutils literal"><span class="pre">~x.in_(y)</span></tt>.</p>
<div class="versionadded">
<p><span>New in version 0.8.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.in_" title="sqlalchemy.sql.operators.ColumnOperators.in_"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.in_()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.notlike">
<tt class="descname">notlike</tt><big>(</big><em>other</em>, <em>escape=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.notlike" title="Permalink to this definition">¶</a></dt>
<dd><p>implement the <tt class="docutils literal"><span class="pre">NOT</span> <span class="pre">LIKE</span></tt> operator.</p>
<p>This is equivalent to using negation with
<a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like" title="sqlalchemy.sql.operators.ColumnOperators.like"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.like()</span></tt></a>, i.e. <tt class="docutils literal"><span class="pre">~x.like(y)</span></tt>.</p>
<div class="versionadded">
<p><span>New in version 0.8.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.like" title="sqlalchemy.sql.operators.ColumnOperators.like"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.like()</span></tt></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.nullsfirst">
<tt class="descname">nullsfirst</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.nullsfirst" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.nullsfirst" title="sqlalchemy.sql.expression.nullsfirst"><tt class="xref py py-func docutils literal"><span class="pre">nullsfirst()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.nullslast">
<tt class="descname">nullslast</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.nullslast" title="Permalink to this definition">¶</a></dt>
<dd><p>Produce a <a class="reference internal" href="#sqlalchemy.sql.expression.nullslast" title="sqlalchemy.sql.expression.nullslast"><tt class="xref py py-func docutils literal"><span class="pre">nullslast()</span></tt></a> clause against the
parent object.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.op">
<tt class="descname">op</tt><big>(</big><em>opstring</em>, <em>precedence=0</em>, <em>is_comparison=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.op" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.op" title="sqlalchemy.sql.operators.Operators.op"><tt class="xref py py-meth docutils literal"><span class="pre">op()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">Operators</span></tt></a></div>
<p>produce a generic operator function.</p>
<p>e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">op</span><span class="p">(</span><span class="s">&quot;*&quot;</span><span class="p">)(</span><span class="mi">5</span><span class="p">)</span></pre></div>
</div>
<p>produces:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span> <span class="o">*</span> <span class="mi">5</span></pre></div>
</div>
<p>This function can also be used to make bitwise operators explicit. For
example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">op</span><span class="p">(</span><span class="s">&#39;&amp;&#39;</span><span class="p">)(</span><span class="mh">0xff</span><span class="p">)</span></pre></div>
</div>
<p>is a bitwise AND of the value in <tt class="docutils literal"><span class="pre">somecolumn</span></tt>.</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.sql.operators.ColumnOperators.op.params.operator"></span><strong>operator</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.op.params.operator">¶</a> &#8211; a string which will be output as the infix operator
between this element and the expression passed to the
generated function.</li>
<li><span class="target" id="sqlalchemy.sql.operators.ColumnOperators.op.params.precedence"></span><strong>precedence</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.op.params.precedence">¶</a> &#8211; <p>precedence to apply to the operator, when
parenthesizing expressions.  A lower number will cause the expression
to be parenthesized when applied against another operator with
higher precedence.  The default value of <tt class="docutils literal"><span class="pre">0</span></tt> is lower than all
operators except for the comma (<tt class="docutils literal"><span class="pre">,</span></tt>) and <tt class="docutils literal"><span class="pre">AS</span></tt> operators.
A value of 100 will be higher or equal to all operators, and -100
will be lower than or equal to all operators.</p>
<div class="versionadded">
<p><span>New in version 0.8: </span>- added the &#8216;precedence&#8217; argument.</p>
</div>
</li>
<li><span class="target" id="sqlalchemy.sql.operators.ColumnOperators.op.params.is_comparison"></span><strong>is_comparison</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.op.params.is_comparison">¶</a> &#8211; <p>if True, the operator will be considered as a
&#8220;comparison&#8221; operator, that is which evaulates to a boolean
true/false value, like <tt class="docutils literal"><span class="pre">==</span></tt>, <tt class="docutils literal"><span class="pre">&gt;</span></tt>, etc.  This flag should be set
so that ORM relationships can establish that the operator is a
comparison operator when used in a custom join condition.</p>
<div class="versionadded">
<p><span>New in version 0.9.2: </span>- added the
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.op.params.is_comparison" title="sqlalchemy.sql.operators.Operators.op"><tt class="xref py py-paramref docutils literal"><span class="pre">Operators.op.is_comparison</span></tt></a> flag.</p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="types.html#types-operators"><em>Redefining and Creating New Operators</em></a></p>
<p class="last"><a class="reference internal" href="../orm/relationships.html#relationship-custom-operator"><em>Using custom operators in join conditions</em></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.operate">
<tt class="descname">operate</tt><big>(</big><em>op</em>, <em>*other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.operate" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.operate" title="sqlalchemy.sql.operators.Operators.operate"><tt class="xref py py-meth docutils literal"><span class="pre">operate()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">Operators</span></tt></a></div>
<p>Operate on an argument.</p>
<p>This is the lowest level of operation, raises
<tt class="xref py py-class docutils literal"><span class="pre">NotImplementedError</span></tt> by default.</p>
<p>Overriding this on a subclass can allow common
behavior to be applied to all operations.
For example, overriding <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a>
to apply <tt class="docutils literal"><span class="pre">func.lower()</span></tt> to the left and right
side:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyComparator</span><span class="p">(</span><span class="n">ColumnOperators</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">operate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">op</span><span class="p">(</span><span class="n">func</span><span class="o">.</span><span class="n">lower</span><span class="p">(</span><span class="bp">self</span><span class="p">),</span> <span class="n">func</span><span class="o">.</span><span class="n">lower</span><span class="p">(</span><span class="n">other</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.sql.operators.ColumnOperators.operate.params.op"></span><strong>op</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.operate.params.op">¶</a> &#8211; Operator callable.</li>
<li><span class="target" id="sqlalchemy.sql.operators.ColumnOperators.operate.params.*other"></span><strong>*other</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.operate.params.*other">¶</a> &#8211; the &#8216;other&#8217; side of the operation. Will
be a single scalar for most operations.</li>
<li><span class="target" id="sqlalchemy.sql.operators.ColumnOperators.operate.params.**kwargs"></span><strong>**kwargs</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.operate.params.**kwargs">¶</a> &#8211; modifiers.  These may be passed by special
operators such as <tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.contains()</span></tt>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.reverse_operate">
<tt class="descname">reverse_operate</tt><big>(</big><em>op</em>, <em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.reverse_operate" title="Permalink to this definition">¶</a></dt>
<dd><div class="inherited-member container">
<em>inherited from the</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators.reverse_operate" title="sqlalchemy.sql.operators.Operators.reverse_operate"><tt class="xref py py-meth docutils literal"><span class="pre">reverse_operate()</span></tt></a> <em>method of</em> <a class="reference internal" href="#sqlalchemy.sql.operators.Operators" title="sqlalchemy.sql.operators.Operators"><tt class="xref py py-class docutils literal"><span class="pre">Operators</span></tt></a></div>
<p>Reverse operate on an argument.</p>
<p>Usage is the same as <tt class="xref py py-meth docutils literal"><span class="pre">operate()</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.ColumnOperators.startswith">
<tt class="descname">startswith</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.startswith" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">startwith</span></tt> operator.</p>
<p>In a column context, produces the clause <tt class="docutils literal"><span class="pre">LIKE</span> <span class="pre">'&lt;other&gt;%'</span></tt></p>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.ColumnOperators.timetuple">
<tt class="descname">timetuple</tt><em class="property"> = None</em><a class="headerlink" href="#sqlalchemy.sql.operators.ColumnOperators.timetuple" title="Permalink to this definition">¶</a></dt>
<dd><p>Hack, allows datetime objects to be compared on the LHS.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.base.DialectKWArgs">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.base.</tt><tt class="descname">DialectKWArgs</tt><a class="headerlink" href="#sqlalchemy.sql.base.DialectKWArgs" title="Permalink to this definition">¶</a></dt>
<dd><p>Establish the ability for a class to have dialect-specific arguments
with defaults and constructor validation.</p>
<p>The <a class="reference internal" href="#sqlalchemy.sql.base.DialectKWArgs" title="sqlalchemy.sql.base.DialectKWArgs"><tt class="xref py py-class docutils literal"><span class="pre">DialectKWArgs</span></tt></a> interacts with the
<a class="reference internal" href="internals.html#sqlalchemy.engine.default.DefaultDialect.construct_arguments" title="sqlalchemy.engine.default.DefaultDialect.construct_arguments"><tt class="xref py py-attr docutils literal"><span class="pre">DefaultDialect.construct_arguments</span></tt></a> present on a dialect.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="internals.html#sqlalchemy.engine.default.DefaultDialect.construct_arguments" title="sqlalchemy.engine.default.DefaultDialect.construct_arguments"><tt class="xref py py-attr docutils literal"><span class="pre">DefaultDialect.construct_arguments</span></tt></a></p>
</div>
<dl class="classmethod">
<dt id="sqlalchemy.sql.base.DialectKWArgs.argument_for">
<em class="property">classmethod </em><tt class="descname">argument_for</tt><big>(</big><em>dialect_name</em>, <em>argument_name</em>, <em>default</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.base.DialectKWArgs.argument_for" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new kind of dialect-specific keyword argument for this class.</p>
<p>E.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Index</span><span class="o">.</span><span class="n">argument_for</span><span class="p">(</span><span class="s">&quot;mydialect&quot;</span><span class="p">,</span> <span class="s">&quot;length&quot;</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>

<span class="n">some_index</span> <span class="o">=</span> <span class="n">Index</span><span class="p">(</span><span class="s">&#39;a&#39;</span><span class="p">,</span> <span class="s">&#39;b&#39;</span><span class="p">,</span> <span class="n">mydialect_length</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.argument_for" title="sqlalchemy.sql.base.DialectKWArgs.argument_for"><tt class="xref py py-meth docutils literal"><span class="pre">DialectKWArgs.argument_for()</span></tt></a> method is a per-argument
way adding extra arguments to the
<a class="reference internal" href="internals.html#sqlalchemy.engine.default.DefaultDialect.construct_arguments" title="sqlalchemy.engine.default.DefaultDialect.construct_arguments"><tt class="xref py py-attr docutils literal"><span class="pre">DefaultDialect.construct_arguments</span></tt></a> dictionary. This
dictionary provides a list of argument names accepted by various
schema-level constructs on behalf of a dialect.</p>
<p>New dialects should typically specify this dictionary all at once as a
data member of the dialect class.  The use case for ad-hoc addition of
argument names is typically for end-user code that is also using
a custom compilation scheme which consumes the additional arguments.</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.sql.base.DialectKWArgs.argument_for.params.dialect_name"></span><strong>dialect_name</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.argument_for.params.dialect_name">¶</a> &#8211; name of a dialect.  The dialect must be
locatable, else a <tt class="xref py py-class docutils literal"><span class="pre">NoSuchModuleError</span></tt> is raised.   The
dialect must also include an existing
<a class="reference internal" href="internals.html#sqlalchemy.engine.default.DefaultDialect.construct_arguments" title="sqlalchemy.engine.default.DefaultDialect.construct_arguments"><tt class="xref py py-attr docutils literal"><span class="pre">DefaultDialect.construct_arguments</span></tt></a> collection, indicating
that it participates in the keyword-argument validation and default
system, else <tt class="xref py py-class docutils literal"><span class="pre">ArgumentError</span></tt> is raised.  If the dialect does
not include this collection, then any keyword argument can be
specified on behalf of this dialect already.  All dialects packaged
within SQLAlchemy include this collection, however for third party
dialects, support may vary.</li>
<li><span class="target" id="sqlalchemy.sql.base.DialectKWArgs.argument_for.params.argument_name"></span><strong>argument_name</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.argument_for.params.argument_name">¶</a> &#8211; name of the parameter.</li>
<li><span class="target" id="sqlalchemy.sql.base.DialectKWArgs.argument_for.params.default"></span><strong>default</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.argument_for.params.default">¶</a> &#8211; default value of the parameter.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span>New in version 0.9.4.</span></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs">
<tt class="descname">dialect_kwargs</tt><a class="headerlink" href="#sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs" title="Permalink to this definition">¶</a></dt>
<dd><p>A collection of keyword arguments specified as dialect-specific
options to this construct.</p>
<p>The arguments are present here in their original <tt class="docutils literal"><span class="pre">&lt;dialect&gt;_&lt;kwarg&gt;</span></tt>
format.  Only arguments that were actually passed are included;
unlike the <a class="reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.dialect_options" title="sqlalchemy.sql.base.DialectKWArgs.dialect_options"><tt class="xref py py-attr docutils literal"><span class="pre">DialectKWArgs.dialect_options</span></tt></a> collection, which
contains all options known by this dialect including defaults.</p>
<p>The collection is also writable; keys are accepted of the
form <tt class="docutils literal"><span class="pre">&lt;dialect&gt;_&lt;kwarg&gt;</span></tt> where the value will be assembled
into the list of options.</p>
<div class="versionadded">
<p><span>New in version 0.9.2.</span></p>
</div>
<div class="versionchanged">
<p><span>Changed in version 0.9.4: </span>The <a class="reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs" title="sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs"><tt class="xref py py-attr docutils literal"><span class="pre">DialectKWArgs.dialect_kwargs</span></tt></a>
collection is now writable.</p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.dialect_options" title="sqlalchemy.sql.base.DialectKWArgs.dialect_options"><tt class="xref py py-attr docutils literal"><span class="pre">DialectKWArgs.dialect_options</span></tt></a> - nested dictionary form</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.base.DialectKWArgs.dialect_options">
<tt class="descname">dialect_options</tt><a class="headerlink" href="#sqlalchemy.sql.base.DialectKWArgs.dialect_options" title="Permalink to this definition">¶</a></dt>
<dd><p>A collection of keyword arguments specified as dialect-specific
options to this construct.</p>
<p>This is a two-level nested registry, keyed to <tt class="docutils literal"><span class="pre">&lt;dialect_name&gt;</span></tt>
and <tt class="docutils literal"><span class="pre">&lt;argument_name&gt;</span></tt>.  For example, the <tt class="docutils literal"><span class="pre">postgresql_where</span></tt>
argument would be locatable as:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">arg</span> <span class="o">=</span> <span class="n">my_object</span><span class="o">.</span><span class="n">dialect_options</span><span class="p">[</span><span class="s">&#39;postgresql&#39;</span><span class="p">][</span><span class="s">&#39;where&#39;</span><span class="p">]</span></pre></div>
</div>
<div class="versionadded">
<p><span>New in version 0.9.2.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs" title="sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs"><tt class="xref py py-attr docutils literal"><span class="pre">DialectKWArgs.dialect_kwargs</span></tt></a> - flat dictionary form</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.base.DialectKWArgs.kwargs">
<tt class="descname">kwargs</tt><a class="headerlink" href="#sqlalchemy.sql.base.DialectKWArgs.kwargs" title="Permalink to this definition">¶</a></dt>
<dd><p>A synonym for <a class="reference internal" href="#sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs" title="sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs"><tt class="xref py py-attr docutils literal"><span class="pre">DialectKWArgs.dialect_kwargs</span></tt></a>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.Extract">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">Extract</tt><big>(</big><em>field</em>, <em>expr</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Extract" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent a SQL EXTRACT clause, <tt class="docutils literal"><span class="pre">extract(field</span> <span class="pre">FROM</span> <span class="pre">expr)</span></tt>.</p>
<dl class="method">
<dt id="sqlalchemy.sql.expression.Extract.__init__">
<tt class="descname">__init__</tt><big>(</big><em>field</em>, <em>expr</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Extract.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.Extract" title="sqlalchemy.sql.expression.Extract"><tt class="xref py py-class docutils literal"><span class="pre">Extract</span></tt></a> object.</p>
<p>This constructor is mirrored as a public API function; see <a class="reference internal" href="#sqlalchemy.sql.expression.extract" title="sqlalchemy.sql.expression.extract"><tt class="xref py py-func docutils literal"><span class="pre">extract()</span></tt></a> for a full usage and argument description.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.elements.False_">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.elements.</tt><tt class="descname">False_</tt><a class="headerlink" href="#sqlalchemy.sql.elements.False_" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent the <tt class="docutils literal"><span class="pre">false</span></tt> keyword, or equivalent, in a SQL statement.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.elements.False_" title="sqlalchemy.sql.elements.False_"><tt class="xref py py-class docutils literal"><span class="pre">False_</span></tt></a> is accessed as a constant via the
<a class="reference internal" href="#sqlalchemy.sql.expression.false" title="sqlalchemy.sql.expression.false"><tt class="xref py py-func docutils literal"><span class="pre">false()</span></tt></a> function.</p>
</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.Label">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">Label</tt><big>(</big><em>name</em>, <em>element</em>, <em>type_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Label" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represents a column label (AS).</p>
<p>Represent a label, as typically applied to any column-level
element using the <tt class="docutils literal"><span class="pre">AS</span></tt> sql keyword.</p>
<dl class="method">
<dt id="sqlalchemy.sql.expression.Label.__init__">
<tt class="descname">__init__</tt><big>(</big><em>name</em>, <em>element</em>, <em>type_=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Label.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.Label" title="sqlalchemy.sql.expression.Label"><tt class="xref py py-class docutils literal"><span class="pre">Label</span></tt></a> object.</p>
<p>This constructor is mirrored as a public API function; see <a class="reference internal" href="#sqlalchemy.sql.expression.label" title="sqlalchemy.sql.expression.label"><tt class="xref py py-func docutils literal"><span class="pre">label()</span></tt></a> for a full usage and argument description.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.elements.Null">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.elements.</tt><tt class="descname">Null</tt><a class="headerlink" href="#sqlalchemy.sql.elements.Null" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent the NULL keyword in a SQL statement.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.elements.Null" title="sqlalchemy.sql.elements.Null"><tt class="xref py py-class docutils literal"><span class="pre">Null</span></tt></a> is accessed as a constant via the
<a class="reference internal" href="#sqlalchemy.sql.expression.null" title="sqlalchemy.sql.expression.null"><tt class="xref py py-func docutils literal"><span class="pre">null()</span></tt></a> function.</p>
</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.Over">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">Over</tt><big>(</big><em>func</em>, <em>partition_by=None</em>, <em>order_by=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Over" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent an OVER clause.</p>
<p>This is a special operator against a so-called
&#8220;window&#8221; function, as well as any aggregate function,
which produces results relative to the result set
itself.  It&#8217;s supported only by certain database
backends.</p>
<dl class="method">
<dt id="sqlalchemy.sql.expression.Over.__init__">
<tt class="descname">__init__</tt><big>(</big><em>func</em>, <em>partition_by=None</em>, <em>order_by=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Over.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.Over" title="sqlalchemy.sql.expression.Over"><tt class="xref py py-class docutils literal"><span class="pre">Over</span></tt></a> object.</p>
<p>This constructor is mirrored as a public API function; see <a class="reference internal" href="#sqlalchemy.sql.expression.over" title="sqlalchemy.sql.expression.over"><tt class="xref py py-func docutils literal"><span class="pre">over()</span></tt></a> for a full usage and argument description.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.TextClause">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">TextClause</tt><big>(</big><em>text</em>, <em>bind=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.TextClause" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.Executable" title="sqlalchemy.sql.expression.Executable"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.Executable</span></tt></a>, <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ClauseElement</span></tt></a></p>
<p>Represent a literal SQL text fragment.</p>
<p>E.g.:</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">text</span>

<span class="n">t</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT * FROM users&quot;</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">t</span><span class="p">)</span></pre></div>
</div>
<p>The <a class="reference internal" href="types.html#sqlalchemy.types.Text" title="sqlalchemy.types.Text"><tt class="xref py py-class docutils literal"><span class="pre">Text</span></tt></a> construct is produced using the <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a>
function; see that function for full documentation.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a></p>
</div>
<dl class="method">
<dt id="sqlalchemy.sql.expression.TextClause.bindparams">
<tt class="descname">bindparams</tt><big>(</big><em>*binds</em>, <em>**names_to_values</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.TextClause.bindparams" title="Permalink to this definition">¶</a></dt>
<dd><p>Establish the values and/or types of bound parameters within
this <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause" title="sqlalchemy.sql.expression.TextClause"><tt class="xref py py-class docutils literal"><span class="pre">TextClause</span></tt></a> construct.</p>
<p>Given a text construct such as:</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">text</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT id, name FROM user WHERE name=:name &quot;</span>
            <span class="s">&quot;AND timestamp=:timestamp&quot;</span><span class="p">)</span></pre></div>
</div>
<p>the <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.bindparams" title="sqlalchemy.sql.expression.TextClause.bindparams"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.bindparams()</span></tt></a> method can be used to establish
the initial value of <tt class="docutils literal"><span class="pre">:name</span></tt> and <tt class="docutils literal"><span class="pre">:timestamp</span></tt>,
using simple keyword arguments:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">stmt</span><span class="o">.</span><span class="n">bindparams</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&#39;jack&#39;</span><span class="p">,</span>
            <span class="n">timestamp</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="mi">2012</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span></pre></div>
</div>
<p>Where above, new <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> objects
will be generated with the names <tt class="docutils literal"><span class="pre">name</span></tt> and <tt class="docutils literal"><span class="pre">timestamp</span></tt>, and
values of <tt class="docutils literal"><span class="pre">jack</span></tt> and <tt class="docutils literal"><span class="pre">datetime.datetime(2012,</span> <span class="pre">10,</span> <span class="pre">8,</span> <span class="pre">15,</span> <span class="pre">12,</span> <span class="pre">5)</span></tt>,
respectively.  The types will be
inferred from the values given, in this case <a class="reference internal" href="types.html#sqlalchemy.types.String" title="sqlalchemy.types.String"><tt class="xref py py-class docutils literal"><span class="pre">String</span></tt></a> and
<a class="reference internal" href="types.html#sqlalchemy.types.DateTime" title="sqlalchemy.types.DateTime"><tt class="xref py py-class docutils literal"><span class="pre">DateTime</span></tt></a>.</p>
<p>When specific typing behavior is needed, the positional <tt class="docutils literal"><span class="pre">*binds</span></tt>
argument can be used in which to specify <a class="reference internal" href="#sqlalchemy.sql.expression.bindparam" title="sqlalchemy.sql.expression.bindparam"><tt class="xref py py-func docutils literal"><span class="pre">bindparam()</span></tt></a> constructs
directly.  These constructs must include at least the <tt class="docutils literal"><span class="pre">key</span></tt>
argument, then an optional value and type:</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">bindparam</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">stmt</span><span class="o">.</span><span class="n">bindparams</span><span class="p">(</span>
                <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;name&#39;</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="s">&#39;jack&#39;</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">String</span><span class="p">),</span>
                <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;timestamp&#39;</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">DateTime</span><span class="p">)</span>
            <span class="p">)</span></pre></div>
</div>
<p>Above, we specified the type of <a class="reference internal" href="types.html#sqlalchemy.types.DateTime" title="sqlalchemy.types.DateTime"><tt class="xref py py-class docutils literal"><span class="pre">DateTime</span></tt></a> for the
<tt class="docutils literal"><span class="pre">timestamp</span></tt> bind, and the type of <a class="reference internal" href="types.html#sqlalchemy.types.String" title="sqlalchemy.types.String"><tt class="xref py py-class docutils literal"><span class="pre">String</span></tt></a> for the <tt class="docutils literal"><span class="pre">name</span></tt>
bind.  In the case of <tt class="docutils literal"><span class="pre">name</span></tt> we also set the default value of
<tt class="docutils literal"><span class="pre">&quot;jack&quot;</span></tt>.</p>
<p>Additional bound parameters can be supplied at statement execution
time, e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">result</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">stmt</span><span class="p">,</span>
            <span class="n">timestamp</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="mi">2012</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.bindparams" title="sqlalchemy.sql.expression.TextClause.bindparams"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.bindparams()</span></tt></a> method can be called repeatedly,
where it will re-use existing <a class="reference internal" href="#sqlalchemy.sql.expression.BindParameter" title="sqlalchemy.sql.expression.BindParameter"><tt class="xref py py-class docutils literal"><span class="pre">BindParameter</span></tt></a> objects to add
new information.  For example, we can call
<a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.bindparams" title="sqlalchemy.sql.expression.TextClause.bindparams"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.bindparams()</span></tt></a> first with typing information, and a
second time with value information, and it will be combined:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT id, name FROM user WHERE name=:name &quot;</span>
            <span class="s">&quot;AND timestamp=:timestamp&quot;</span><span class="p">)</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">stmt</span><span class="o">.</span><span class="n">bindparams</span><span class="p">(</span>
    <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;name&#39;</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">String</span><span class="p">),</span>
    <span class="n">bindparam</span><span class="p">(</span><span class="s">&#39;timestamp&#39;</span><span class="p">,</span> <span class="n">type_</span><span class="o">=</span><span class="n">DateTime</span><span class="p">)</span>
<span class="p">)</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">stmt</span><span class="o">.</span><span class="n">bindparams</span><span class="p">(</span>
    <span class="n">name</span><span class="o">=</span><span class="s">&#39;jack&#39;</span><span class="p">,</span>
    <span class="n">timestamp</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="mi">2012</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="p">)</span></pre></div>
</div>
<div class="versionadded">
<p><span>New in version 0.9.0: </span>The <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.bindparams" title="sqlalchemy.sql.expression.TextClause.bindparams"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.bindparams()</span></tt></a> method
supersedes the argument <tt class="docutils literal"><span class="pre">bindparams</span></tt> passed to
<a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.expression.TextClause.columns">
<tt class="descname">columns</tt><big>(</big><em>*cols</em>, <em>**types</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.TextClause.columns" title="Permalink to this definition">¶</a></dt>
<dd><p>Turn this <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause" title="sqlalchemy.sql.expression.TextClause"><tt class="xref py py-class docutils literal"><span class="pre">TextClause</span></tt></a> object into a <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.TextAsFrom" title="sqlalchemy.sql.expression.TextAsFrom"><tt class="xref py py-class docutils literal"><span class="pre">TextAsFrom</span></tt></a>
object that can be embedded into another statement.</p>
<p>This function essentially bridges the gap between an entirely
textual SELECT statement and the SQL expression language concept
of a &#8220;selectable&#8221;:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">column</span><span class="p">,</span> <span class="n">text</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT id, name FROM some_table&quot;</span><span class="p">)</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">stmt</span><span class="o">.</span><span class="n">columns</span><span class="p">(</span><span class="n">column</span><span class="p">(</span><span class="s">&#39;id&#39;</span><span class="p">),</span> <span class="n">column</span><span class="p">(</span><span class="s">&#39;name&#39;</span><span class="p">))</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="s">&#39;st&#39;</span><span class="p">)</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">mytable</span><span class="p">])</span><span class="o">.</span>\
        <span class="n">select_from</span><span class="p">(</span>
            <span class="n">mytable</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">stmt</span><span class="p">,</span> <span class="n">mytable</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="n">stmt</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
        <span class="p">)</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">stmt</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">id</span> <span class="o">&gt;</span> <span class="mi">5</span><span class="p">)</span></pre></div>
</div>
<p>Above, we used untyped <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> elements.  These can also have
types specified, which will impact how the column behaves in
expressions as well as determining result set behavior:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT id, name, timestamp FROM some_table&quot;</span><span class="p">)</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">stmt</span><span class="o">.</span><span class="n">columns</span><span class="p">(</span>
            <span class="n">column</span><span class="p">(</span><span class="s">&#39;id&#39;</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">&#39;name&#39;</span><span class="p">,</span> <span class="n">Unicode</span><span class="p">),</span>
            <span class="n">column</span><span class="p">(</span><span class="s">&#39;timestamp&#39;</span><span class="p">,</span> <span class="n">DateTime</span><span class="p">)</span>
        <span class="p">)</span>

<span class="k">for</span> <span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">timestamp</span> <span class="ow">in</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">stmt</span><span class="p">):</span>
    <span class="k">print</span><span class="p">(</span><span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">timestamp</span><span class="p">)</span></pre></div>
</div>
<p>Keyword arguments allow just the names and types of columns to be
specified, where the <a class="reference internal" href="#sqlalchemy.sql.expression.column" title="sqlalchemy.sql.expression.column"><tt class="xref py py-func docutils literal"><span class="pre">column()</span></tt></a> elements will be generated
automatically:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">text</span><span class="p">(</span><span class="s">&quot;SELECT id, name, timestamp FROM some_table&quot;</span><span class="p">)</span>
<span class="n">stmt</span> <span class="o">=</span> <span class="n">stmt</span><span class="o">.</span><span class="n">columns</span><span class="p">(</span>
            <span class="nb">id</span><span class="o">=</span><span class="n">Integer</span><span class="p">,</span>
            <span class="n">name</span><span class="o">=</span><span class="n">Unicode</span><span class="p">,</span>
            <span class="n">timestamp</span><span class="o">=</span><span class="n">DateTime</span>
        <span class="p">)</span>

<span class="k">for</span> <span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">timestamp</span> <span class="ow">in</span> <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="n">stmt</span><span class="p">):</span>
    <span class="k">print</span><span class="p">(</span><span class="nb">id</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">timestamp</span><span class="p">)</span></pre></div>
</div>
<p>The <a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.columns" title="sqlalchemy.sql.expression.TextClause.columns"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.columns()</span></tt></a> method provides a direct
route to calling <a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.FromClause.alias" title="sqlalchemy.sql.expression.FromClause.alias"><tt class="xref py py-meth docutils literal"><span class="pre">FromClause.alias()</span></tt></a> as well as
<a class="reference internal" href="selectable.html#sqlalchemy.sql.expression.SelectBase.cte" title="sqlalchemy.sql.expression.SelectBase.cte"><tt class="xref py py-meth docutils literal"><span class="pre">SelectBase.cte()</span></tt></a> against a textual SELECT statement:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">stmt</span> <span class="o">=</span> <span class="n">stmt</span><span class="o">.</span><span class="n">columns</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">Integer</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">String</span><span class="p">)</span><span class="o">.</span><span class="n">cte</span><span class="p">(</span><span class="s">&#39;st&#39;</span><span class="p">)</span>

<span class="n">stmt</span> <span class="o">=</span> <span class="n">select</span><span class="p">([</span><span class="n">sometable</span><span class="p">])</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">sometable</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">id</span> <span class="o">==</span> <span class="n">stmt</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">id</span><span class="p">)</span></pre></div>
</div>
<div class="versionadded">
<p><span>New in version 0.9.0: </span><a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a> can now be converted into a
fully featured &#8220;selectable&#8221; construct using the
<a class="reference internal" href="#sqlalchemy.sql.expression.TextClause.columns" title="sqlalchemy.sql.expression.TextClause.columns"><tt class="xref py py-meth docutils literal"><span class="pre">TextClause.columns()</span></tt></a> method.  This method supersedes the
<tt class="docutils literal"><span class="pre">typemap</span></tt> argument to <a class="reference internal" href="#sqlalchemy.sql.expression.text" title="sqlalchemy.sql.expression.text"><tt class="xref py py-func docutils literal"><span class="pre">text()</span></tt></a>.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.Tuple">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">Tuple</tt><big>(</big><em>*clauses</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Tuple" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ClauseList" title="sqlalchemy.sql.expression.ClauseList"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ClauseList</span></tt></a>, <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent a SQL tuple.</p>
<dl class="method">
<dt id="sqlalchemy.sql.expression.Tuple.__init__">
<tt class="descname">__init__</tt><big>(</big><em>*clauses</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.Tuple.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new <a class="reference internal" href="#sqlalchemy.sql.expression.Tuple" title="sqlalchemy.sql.expression.Tuple"><tt class="xref py py-class docutils literal"><span class="pre">Tuple</span></tt></a> object.</p>
<p>This constructor is mirrored as a public API function; see <a class="reference internal" href="#sqlalchemy.sql.expression.tuple_" title="sqlalchemy.sql.expression.tuple_"><tt class="xref py py-func docutils literal"><span class="pre">tuple_()</span></tt></a> for a full usage and argument description.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.elements.True_">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.elements.</tt><tt class="descname">True_</tt><a class="headerlink" href="#sqlalchemy.sql.elements.True_" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Represent the <tt class="docutils literal"><span class="pre">true</span></tt> keyword, or equivalent, in a SQL statement.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.elements.True_" title="sqlalchemy.sql.elements.True_"><tt class="xref py py-class docutils literal"><span class="pre">True_</span></tt></a> is accessed as a constant via the
<a class="reference internal" href="#sqlalchemy.sql.expression.true" title="sqlalchemy.sql.expression.true"><tt class="xref py py-func docutils literal"><span class="pre">true()</span></tt></a> function.</p>
</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.operators.custom_op">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.operators.</tt><tt class="descname">custom_op</tt><big>(</big><em>opstring</em>, <em>precedence=0</em>, <em>is_comparison=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.custom_op" title="Permalink to this definition">¶</a></dt>
<dd><p>Represent a &#8216;custom&#8217; operator.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.operators.custom_op" title="sqlalchemy.sql.operators.custom_op"><tt class="xref py py-class docutils literal"><span class="pre">custom_op</span></tt></a> is normally instantitated when the
<a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators.op" title="sqlalchemy.sql.operators.ColumnOperators.op"><tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.op()</span></tt></a> method is used to create a
custom operator callable.  The class can also be used directly
when programmatically constructing expressions.   E.g.
to represent the &#8220;factorial&#8221; operation:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">UnaryExpression</span>
<span class="kn">from</span> <span class="nn">sqlalchemy.sql</span> <span class="kn">import</span> <span class="n">operators</span>
<span class="kn">from</span> <span class="nn">sqlalchemy</span> <span class="kn">import</span> <span class="n">Numeric</span>

<span class="n">unary</span> <span class="o">=</span> <span class="n">UnaryExpression</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">somecolumn</span><span class="p">,</span>
        <span class="n">modifier</span><span class="o">=</span><span class="n">operators</span><span class="o">.</span><span class="n">custom_op</span><span class="p">(</span><span class="s">&quot;!&quot;</span><span class="p">),</span>
        <span class="n">type_</span><span class="o">=</span><span class="n">Numeric</span><span class="p">)</span></pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.operators.Operators">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.operators.</tt><tt class="descname">Operators</tt><a class="headerlink" href="#sqlalchemy.sql.operators.Operators" title="Permalink to this definition">¶</a></dt>
<dd><p>Base of comparison and logical operators.</p>
<p>Implements base methods
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.operate" title="sqlalchemy.sql.operators.Operators.operate"><tt class="xref py py-meth docutils literal"><span class="pre">operate()</span></tt></a> and
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.reverse_operate" title="sqlalchemy.sql.operators.Operators.reverse_operate"><tt class="xref py py-meth docutils literal"><span class="pre">reverse_operate()</span></tt></a>, as well as
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.__and__" title="sqlalchemy.sql.operators.Operators.__and__"><tt class="xref py py-meth docutils literal"><span class="pre">__and__()</span></tt></a>,
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.__or__" title="sqlalchemy.sql.operators.Operators.__or__"><tt class="xref py py-meth docutils literal"><span class="pre">__or__()</span></tt></a>,
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.__invert__" title="sqlalchemy.sql.operators.Operators.__invert__"><tt class="xref py py-meth docutils literal"><span class="pre">__invert__()</span></tt></a>.</p>
<p>Usually is used via its most common subclass
<a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a>.</p>
<dl class="method">
<dt id="sqlalchemy.sql.operators.Operators.__and__">
<tt class="descname">__and__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.Operators.__and__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">&amp;</span></tt> operator.</p>
<p>When used with SQL expressions, results in an
AND operation, equivalent to
<a class="reference internal" href="#sqlalchemy.sql.expression.and_" title="sqlalchemy.sql.expression.and_"><tt class="xref py py-func docutils literal"><span class="pre">and_()</span></tt></a>, that is:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">a</span> <span class="o">&amp;</span> <span class="n">b</span></pre></div>
</div>
<p>is equivalent to:</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">and_</span>
<span class="n">and_</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span></pre></div>
</div>
<p>Care should be taken when using <tt class="docutils literal"><span class="pre">&amp;</span></tt> regarding
operator precedence; the <tt class="docutils literal"><span class="pre">&amp;</span></tt> operator has the highest precedence.
The operands should be enclosed in parenthesis if they contain
further sub expressions:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">(</span><span class="n">a</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="o">&amp;</span> <span class="p">(</span><span class="n">b</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span></pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.Operators.__invert__">
<tt class="descname">__invert__</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.Operators.__invert__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">~</span></tt> operator.</p>
<p>When used with SQL expressions, results in a
NOT operation, equivalent to
<a class="reference internal" href="#sqlalchemy.sql.expression.not_" title="sqlalchemy.sql.expression.not_"><tt class="xref py py-func docutils literal"><span class="pre">not_()</span></tt></a>, that is:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="o">~</span><span class="n">a</span></pre></div>
</div>
<p>is equivalent to:</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">not_</span>
<span class="n">not_</span><span class="p">(</span><span class="n">a</span><span class="p">)</span></pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.Operators.__or__">
<tt class="descname">__or__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.Operators.__or__" title="Permalink to this definition">¶</a></dt>
<dd><p>Implement the <tt class="docutils literal"><span class="pre">|</span></tt> operator.</p>
<p>When used with SQL expressions, results in an
OR operation, equivalent to
<a class="reference internal" href="#sqlalchemy.sql.expression.or_" title="sqlalchemy.sql.expression.or_"><tt class="xref py py-func docutils literal"><span class="pre">or_()</span></tt></a>, that is:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">a</span> <span class="o">|</span> <span class="n">b</span></pre></div>
</div>
<p>is equivalent to:</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">or_</span>
<span class="n">or_</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span></pre></div>
</div>
<p>Care should be taken when using <tt class="docutils literal"><span class="pre">|</span></tt> regarding
operator precedence; the <tt class="docutils literal"><span class="pre">|</span></tt> operator has the highest precedence.
The operands should be enclosed in parenthesis if they contain
further sub expressions:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">(</span><span class="n">a</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span><span class="n">b</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span></pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="sqlalchemy.sql.operators.Operators.__weakref__">
<tt class="descname">__weakref__</tt><a class="headerlink" href="#sqlalchemy.sql.operators.Operators.__weakref__" title="Permalink to this definition">¶</a></dt>
<dd><p>list of weak references to the object (if defined)</p>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.Operators.op">
<tt class="descname">op</tt><big>(</big><em>opstring</em>, <em>precedence=0</em>, <em>is_comparison=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.Operators.op" title="Permalink to this definition">¶</a></dt>
<dd><p>produce a generic operator function.</p>
<p>e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">op</span><span class="p">(</span><span class="s">&quot;*&quot;</span><span class="p">)(</span><span class="mi">5</span><span class="p">)</span></pre></div>
</div>
<p>produces:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span> <span class="o">*</span> <span class="mi">5</span></pre></div>
</div>
<p>This function can also be used to make bitwise operators explicit. For
example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">somecolumn</span><span class="o">.</span><span class="n">op</span><span class="p">(</span><span class="s">&#39;&amp;&#39;</span><span class="p">)(</span><span class="mh">0xff</span><span class="p">)</span></pre></div>
</div>
<p>is a bitwise AND of the value in <tt class="docutils literal"><span class="pre">somecolumn</span></tt>.</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.sql.operators.Operators.op.params.operator"></span><strong>operator</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.Operators.op.params.operator">¶</a> &#8211; a string which will be output as the infix operator
between this element and the expression passed to the
generated function.</li>
<li><span class="target" id="sqlalchemy.sql.operators.Operators.op.params.precedence"></span><strong>precedence</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.Operators.op.params.precedence">¶</a> &#8211; <p>precedence to apply to the operator, when
parenthesizing expressions.  A lower number will cause the expression
to be parenthesized when applied against another operator with
higher precedence.  The default value of <tt class="docutils literal"><span class="pre">0</span></tt> is lower than all
operators except for the comma (<tt class="docutils literal"><span class="pre">,</span></tt>) and <tt class="docutils literal"><span class="pre">AS</span></tt> operators.
A value of 100 will be higher or equal to all operators, and -100
will be lower than or equal to all operators.</p>
<div class="versionadded">
<p><span>New in version 0.8: </span>- added the &#8216;precedence&#8217; argument.</p>
</div>
</li>
<li><span class="target" id="sqlalchemy.sql.operators.Operators.op.params.is_comparison"></span><strong>is_comparison</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.Operators.op.params.is_comparison">¶</a> &#8211; <p>if True, the operator will be considered as a
&#8220;comparison&#8221; operator, that is which evaulates to a boolean
true/false value, like <tt class="docutils literal"><span class="pre">==</span></tt>, <tt class="docutils literal"><span class="pre">&gt;</span></tt>, etc.  This flag should be set
so that ORM relationships can establish that the operator is a
comparison operator when used in a custom join condition.</p>
<div class="versionadded">
<p><span>New in version 0.9.2: </span>- added the
<a class="reference internal" href="#sqlalchemy.sql.operators.Operators.op.params.is_comparison" title="sqlalchemy.sql.operators.Operators.op"><tt class="xref py py-paramref docutils literal"><span class="pre">Operators.op.is_comparison</span></tt></a> flag.</p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="types.html#types-operators"><em>Redefining and Creating New Operators</em></a></p>
<p class="last"><a class="reference internal" href="../orm/relationships.html#relationship-custom-operator"><em>Using custom operators in join conditions</em></a></p>
</div>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.Operators.operate">
<tt class="descname">operate</tt><big>(</big><em>op</em>, <em>*other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.Operators.operate" title="Permalink to this definition">¶</a></dt>
<dd><p>Operate on an argument.</p>
<p>This is the lowest level of operation, raises
<tt class="xref py py-class docutils literal"><span class="pre">NotImplementedError</span></tt> by default.</p>
<p>Overriding this on a subclass can allow common
behavior to be applied to all operations.
For example, overriding <a class="reference internal" href="#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">ColumnOperators</span></tt></a>
to apply <tt class="docutils literal"><span class="pre">func.lower()</span></tt> to the left and right
side:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyComparator</span><span class="p">(</span><span class="n">ColumnOperators</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">operate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">op</span><span class="p">(</span><span class="n">func</span><span class="o">.</span><span class="n">lower</span><span class="p">(</span><span class="bp">self</span><span class="p">),</span> <span class="n">func</span><span class="o">.</span><span class="n">lower</span><span class="p">(</span><span class="n">other</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.sql.operators.Operators.operate.params.op"></span><strong>op</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.Operators.operate.params.op">¶</a> &#8211; Operator callable.</li>
<li><span class="target" id="sqlalchemy.sql.operators.Operators.operate.params.*other"></span><strong>*other</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.Operators.operate.params.*other">¶</a> &#8211; the &#8216;other&#8217; side of the operation. Will
be a single scalar for most operations.</li>
<li><span class="target" id="sqlalchemy.sql.operators.Operators.operate.params.**kwargs"></span><strong>**kwargs</strong><a class="paramlink headerlink reference internal" href="#sqlalchemy.sql.operators.Operators.operate.params.**kwargs">¶</a> &#8211; modifiers.  These may be passed by special
operators such as <tt class="xref py py-meth docutils literal"><span class="pre">ColumnOperators.contains()</span></tt>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="sqlalchemy.sql.operators.Operators.reverse_operate">
<tt class="descname">reverse_operate</tt><big>(</big><em>op</em>, <em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.operators.Operators.reverse_operate" title="Permalink to this definition">¶</a></dt>
<dd><p>Reverse operate on an argument.</p>
<p>Usage is the same as <tt class="xref py py-meth docutils literal"><span class="pre">operate()</span></tt>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.elements.quoted_name">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.elements.</tt><tt class="descname">quoted_name</tt><a class="headerlink" href="#sqlalchemy.sql.elements.quoted_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">__builtin__.unicode</span></tt></p>
<p>Represent a SQL identifier combined with quoting preferences.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.elements.quoted_name" title="sqlalchemy.sql.elements.quoted_name"><tt class="xref py py-class docutils literal"><span class="pre">quoted_name</span></tt></a> is a Python unicode/str subclass which
represents a particular identifier name along with a
<tt class="docutils literal"><span class="pre">quote</span></tt> flag.  This <tt class="docutils literal"><span class="pre">quote</span></tt> flag, when set to
<tt class="docutils literal"><span class="pre">True</span></tt> or <tt class="docutils literal"><span class="pre">False</span></tt>, overrides automatic quoting behavior
for this identifier in order to either unconditionally quote
or to not quote the name.  If left at its default of <tt class="docutils literal"><span class="pre">None</span></tt>,
quoting behavior is applied to the identifier on a per-backend basis
based on an examination of the token itself.</p>
<p>A <a class="reference internal" href="#sqlalchemy.sql.elements.quoted_name" title="sqlalchemy.sql.elements.quoted_name"><tt class="xref py py-class docutils literal"><span class="pre">quoted_name</span></tt></a> object with <tt class="docutils literal"><span class="pre">quote=True</span></tt> is also
prevented from being modified in the case of a so-called
&#8220;name normalize&#8221; option.  Certain database backends, such as
Oracle, Firebird, and DB2 &#8220;normalize&#8221; case-insensitive names
as uppercase.  The SQLAlchemy dialects for these backends
convert from SQLAlchemy&#8217;s lower-case-means-insensitive convention
to the upper-case-means-insensitive conventions of those backends.
The <tt class="docutils literal"><span class="pre">quote=True</span></tt> flag here will prevent this conversion from occurring
to support an identifier that&#8217;s quoted as all lower case against
such a backend.</p>
<p>The <a class="reference internal" href="#sqlalchemy.sql.elements.quoted_name" title="sqlalchemy.sql.elements.quoted_name"><tt class="xref py py-class docutils literal"><span class="pre">quoted_name</span></tt></a> object is normally created automatically
when specifying the name for key schema constructs such as
<a class="reference internal" href="metadata.html#sqlalchemy.schema.Table" title="sqlalchemy.schema.Table"><tt class="xref py py-class docutils literal"><span class="pre">Table</span></tt></a>, <a class="reference internal" href="metadata.html#sqlalchemy.schema.Column" title="sqlalchemy.schema.Column"><tt class="xref py py-class docutils literal"><span class="pre">Column</span></tt></a>, and others.  The class can also be
passed explicitly as the name to any function that receives a name which
can be quoted.  Such as to use the <a class="reference internal" href="connections.html#sqlalchemy.engine.Engine.has_table" title="sqlalchemy.engine.Engine.has_table"><tt class="xref py py-meth docutils literal"><span class="pre">Engine.has_table()</span></tt></a> method with
an unconditionally quoted name:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlaclchemy</span> <span class="kn">import</span> <span class="n">create_engine</span>
<span class="kn">from</span> <span class="nn">sqlalchemy.sql.elements</span> <span class="kn">import</span> <span class="n">quoted_name</span>

<span class="n">engine</span> <span class="o">=</span> <span class="n">create_engine</span><span class="p">(</span><span class="s">&quot;oracle+cx_oracle://some_dsn&quot;</span><span class="p">)</span>
<span class="n">engine</span><span class="o">.</span><span class="n">has_table</span><span class="p">(</span><span class="n">quoted_name</span><span class="p">(</span><span class="s">&quot;some_table&quot;</span><span class="p">,</span> <span class="bp">True</span><span class="p">))</span></pre></div>
</div>
<p>The above logic will run the &#8220;has table&#8221; logic against the Oracle backend,
passing the name exactly as <tt class="docutils literal"><span class="pre">&quot;some_table&quot;</span></tt> without converting to
upper case.</p>
<div class="versionadded">
<p><span>New in version 0.9.0.</span></p>
</div>
</dd></dl>

<dl class="class">
<dt id="sqlalchemy.sql.expression.UnaryExpression">
<em class="property">class </em><tt class="descclassname">sqlalchemy.sql.expression.</tt><tt class="descname">UnaryExpression</tt><big>(</big><em>element</em>, <em>operator=None</em>, <em>modifier=None</em>, <em>type_=None</em>, <em>negate=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.UnaryExpression" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.sql.expression.ColumnElement" title="sqlalchemy.sql.expression.ColumnElement"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.expression.ColumnElement</span></tt></a></p>
<p>Define a &#8216;unary&#8217; expression.</p>
<p>A unary expression has a single column expression
and an operator.  The operator can be placed on the left
(where it is called the &#8216;operator&#8217;) or right (where it is called the
&#8216;modifier&#8217;) of the column expression.</p>
<p><a class="reference internal" href="#sqlalchemy.sql.expression.UnaryExpression" title="sqlalchemy.sql.expression.UnaryExpression"><tt class="xref py py-class docutils literal"><span class="pre">UnaryExpression</span></tt></a> is the basis for several unary operators
including those used by <a class="reference internal" href="#sqlalchemy.sql.expression.desc" title="sqlalchemy.sql.expression.desc"><tt class="xref py py-func docutils literal"><span class="pre">desc()</span></tt></a>, <a class="reference internal" href="#sqlalchemy.sql.expression.asc" title="sqlalchemy.sql.expression.asc"><tt class="xref py py-func docutils literal"><span class="pre">asc()</span></tt></a>, <a class="reference internal" href="#sqlalchemy.sql.expression.distinct" title="sqlalchemy.sql.expression.distinct"><tt class="xref py py-func docutils literal"><span class="pre">distinct()</span></tt></a>,
<a class="reference internal" href="#sqlalchemy.sql.expression.nullsfirst" title="sqlalchemy.sql.expression.nullsfirst"><tt class="xref py py-func docutils literal"><span class="pre">nullsfirst()</span></tt></a> and <a class="reference internal" href="#sqlalchemy.sql.expression.nullslast" title="sqlalchemy.sql.expression.nullslast"><tt class="xref py py-func docutils literal"><span class="pre">nullslast()</span></tt></a>.</p>
<dl class="method">
<dt id="sqlalchemy.sql.expression.UnaryExpression.compare">
<tt class="descname">compare</tt><big>(</big><em>other</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.sql.expression.UnaryExpression.compare" title="Permalink to this definition">¶</a></dt>
<dd><p>Compare this <a class="reference internal" href="#sqlalchemy.sql.expression.UnaryExpression" title="sqlalchemy.sql.expression.UnaryExpression"><tt class="xref py py-class docutils literal"><span class="pre">UnaryExpression</span></tt></a> against the given
<a class="reference internal" href="#sqlalchemy.sql.expression.ClauseElement" title="sqlalchemy.sql.expression.ClauseElement"><tt class="xref py py-class docutils literal"><span class="pre">ClauseElement</span></tt></a>.</p>
</dd></dl>

</dd></dl>

</div>

    </div>

</div>

<div id="docs-bottom-navigation" class="docs-navigation-links">
        Previous:
        <a href="expression_api.html" title="previous chapter">SQL Statements and Expressions API</a>
        Next:
        <a href="selectable.html" title="next chapter">Selectables, Tables, FROM objects</a>

    <div id="docs-copyright">
        &copy; <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>