Skip to content

Instantly share code, notes, and snippets.

View zzzeek's full-sized avatar
💭
SQLAlchemy 2.0 is released!

Michael Bayer zzzeek

💭
SQLAlchemy 2.0 is released!
View GitHub Profile
@zzzeek
zzzeek / gist:5375840
Created April 12, 2013 22:53
two factor auth. stick your various provider's one-time keys in the dictionary there (the thing you get from the QR code)
#!/usr/local/bin/python
keys = {
'some_provider':'SOMEKEYTHATISABIGSTRINGRIGHTHERE'
}
import hmac, base64, struct, hashlib, time
def get_hotp_token(secret, intervals_no):
key = base64.b32decode(secret, True)
@zzzeek
zzzeek / gist:5545198
Last active December 17, 2015 03:39
"top 100 distinct customers with single biggest transactions"
from sqlalchemy import Integer, String, create_engine, Column, func, ForeignKey
from sqlalchemy.orm import Session
from sqlalchemy.ext.declarative import declarative_base
import random
Base = declarative_base()
class Customer(Base):
__tablename__ = 'customer'
@zzzeek
zzzeek / gist:5557643
Last active December 17, 2015 05:28
attempting to come up with an example of subclassing enums
class CoinType(Enum):
"types of coins we keep track of."
penny = 1
nickel = 2
dime = 3
quarter = 4
dollar = 5
class DefaultCoinUsage(CoinType):
"""Represent what coin type the administration
diff --git a/CHANGES b/CHANGES
index e8ffb1f..c10658c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,9 @@
0.8.1
+- [bug] Changed setup.py to skip installing markupsafe
+ if Python version is < 2.6 or is between 3.0 and
+ less than 3.2, as Markupsafe now only supports 2.6->2.X,
+ 3.2->3.X. [ticket:216]
--- trac/ticket/templates/ticket.html 2013-01-31 19:47:40.000000000 -0500
+++ trac/ticket/templates/ticket.html 2013-05-27 12:40:14.000000000 -0400
@@ -326,6 +326,22 @@
$controls
<span class="hint" py:for="hint in hints">$hint</span>
</div>
+
+ <py:for each="field in fields">
+ <py:choose>
+ <span py:when="field.cc_entry"><!--! Special case for Cc: field -->
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 5820cb1..f26ca12 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -1262,6 +1262,14 @@ def false():
return False_()
+_unhashable = object()
+def _hash(*values):
0.8:
SELECT a.id AS a_id, anon_1.c_id_1 AS anon_1_c_id_1, anon_1.c_base_id AS anon_1_c_base_id,
anon_1.c_c_id AS anon_1_c_c_id, anon_2.b_id AS anon_2_b_id, anon_2.b_base_id AS anon_2_b_base_id,
anon_2.b_a_id AS anon_2_b_a_id
FROM a LEFT OUTER JOIN (SELECT b_base.id AS b_base_id, b.id AS b_id, b.a_id AS b_a_id
FROM b_base JOIN b ON b_base.id = b.id) AS anon_2 ON a.id = anon_2.b_a_id
LEFT OUTER JOIN (SELECT c_base.id AS c_base_id, c.id AS c_id_1, c.c_id AS c_c_id
FROM c_base JOIN c ON c_base.id = c.id) AS anon_1 ON anon_2.b_id = anon_1.c_c_id
Does this SQL work on your database? Need to know for older database versions!!
Postgresql 9.1.4: Y
Oracle 10: Y
SQL Server 2008: Y
MySQL 5.5.15: Y
SQLite 3.7.15: N
MySQL 4.??
MySQL 5.??
The VMware Host-Guest Filesystem allows for shared folders between the host OS
and the guest OS in a Fusion or Workstation virtual environment. Do you wish
to enable this feature? [yes]
Using 2.6.x kernel build system.
make: Entering directory `/tmp/modconfig-OY9Dg4/vmci-only'
/bin/make -C /lib/modules/3.10.3-300.fc19.x86_64/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/kernels/3.10.3-300.fc19.x86_64'
CC [M] /tmp/modconfig-OY9Dg4/vmci-only/linux/driver.o
@zzzeek
zzzeek / gist:6143700
Last active December 20, 2015 14:08
# script: https://github.com/zzzeek/sqlalchemy/blob/master/test/perf/orm2010.py
# cpython 2.7 with no C extensions
classics-MacBook-Pro:sqlalchemy classic$ export PYTHONPATH=lib/
classics-MacBook-Pro:sqlalchemy classic$ python test/perf/orm2010.py
0 - Added 1000 boss objects
3 - Added 100000 grunt objects
29 - Associated grunts w/ bosses and committed
29 - Heavy query run #1
37 - Heavy query run #2