Skip to content

Instantly share code, notes, and snippets.

View skylex72rus's full-sized avatar

skylex72rus

  • SoyuzGeoService
  • Tyumen
View GitHub Profile
@harvimt
harvimt / alchemical_model.py
Created February 2, 2013 20:41
SQLAlchemy to/from PyQt Adapters
#!/usr/bin/env python2
#-*- coding=utf-8 -*-
# © 2013 Mark Harviston, BSD License
from __future__ import absolute_import, unicode_literals, print_function
"""
Qt data models that bind to SQLAlchemy queries
"""
from PyQt4 import QtGui
from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt
import logging # noqa
@gsakkis
gsakkis / render_query.py
Created January 19, 2013 11:25
Generate an SQL expression string with bound parameters rendered inline for the given SQLAlchemy statement.
from datetime import datetime, date
from sqlalchemy.orm.query import Query
def render_query(statement, bind=None):
"""
Generate an SQL expression string with bound parameters rendered inline
for the given SQLAlchemy statement.
WARNING: This method of escaping is insecure, incomplete, and for debugging
purposes only. Executing SQL statements with inline-rendered user values is