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
.venv/bin/pypy: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
New pypy executable in .venv/bin/pypy
ERROR: The executable .venv/bin/pypy is not functioning
ERROR: It thinks sys.prefix is u'/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7' (should be u'/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.venv')
ERROR: virtualenv is not compatible with this system or executable
/var/jenkins/workspace/sqlalchemy-default-sqlite-pypy-2.7/.venv/bin/pypy: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
@zzzeek
zzzeek / gist:10732923
Last active August 29, 2015 13:59
the ever continuing struggle to load a .py file as a module without deprecation warnings
import sys
def load_py_file(path):
if sys.version_info >= (3, 4):
"""???? what goes here ????
load_module() is deprecated? Docs at
https://docs.python.org/3.4/library/importlib.html#importlib.abc.Loader.load_module
https://docs.python.org/3.4/library/importlib.html#importlib.abc.Loader.exec_module
completely unclear, what does "exec_module()" do? is that the replacement?
can we please stop changing the API here?"""
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
@zzzeek
zzzeek / gist:1d47b90718c81a70f4d5
Created May 27, 2014 22:24
deletions of collections
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
-- goal - any time we select FROM my_filtered_table, we want "WHERE my_filtered_table.deleted = 0" added.
-- here's the query:
SELECT * from some_table LEFT OUTER JOIN my_filtered_table ON some_table.id = my_filtered_table.some_id
-- great lets add WHERE:
SELECT * from some_table
LEFT OUTER JOIN my_filtered_table
class Node(Base):
__tablename__ = "node"
id = Column(Integer, primary_key=True)
path = Column(String(500), nullable=False)
depth = Column(Integer, nullable=False)
children = relationship("Node", viewonly=True,
primaryjoin=and_(
remote(foreign(path)).like(path.concat(".%")),
remote(depth) == depth + 1))
"""Rework pip's --download feature to only download files that absolutely
aren't downloaded already.
"""
import pkg_resources
import sys
import os
import re
from pip.commands import install
classics-MacBook-Pro-2:dev classic$ tar -zxf ~/Desktop/tmp/packages/cryptography-0.4.tar.gz
classics-MacBook-Pro-2:dev classic$ cd cryptography-0.4/
classics-MacBook-Pro-2:cryptography-0.4 classic$ python setup.py egg_info
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
@zzzeek
zzzeek / gist:0cec9a5bbf0256f77faf
Created July 9, 2014 19:17
stupidly simple way to integrate setup.py test with pytest
# as opposed to setuptools-dependent http://pytest.org/latest/goodpractises.html#integration-with-setuptools-test-commands
# or non-OSS and incredibly verbose http://pytest.org/latest/goodpractises.html#integrating-with-distutils-python-setup-py-test
# just call this "mypackage.run_disutils" and then
# test_suite="mypackage.run_distutils"
import unittest
import pytest
class TestSuite(unittest.TestCase):
def test_sqlalchemy(self):
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class MyType(TypeDecorator):
impl = Integer
def process_bind_param(self, value, dialect):