bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def _makeSubclassConnectionsPost(new_class): for cls in new_class.__bases__: for weakReceiver, signal in subclassClones.get(cls, []): receiver = weakReceiver() if not receiver: continue listen(receiver, new_class, signal) | def _makeSubclassConnectionsPost(new_class): for cls in new_class.__bases__: for weakReceiver, signal in subclassClones.get(cls, []): receiver = weakReceiver() if not receiver: continue listen(receiver, new_class, signal) | 38,000 |
def __init__(self, tableName, alias=None): Table.__init__(self, tableName) if alias is None: self._alias_lock.acquire() try: AliasTable._alias_counter += 1 alias = "%s_alias%d" % (tableName, AliasTable._alias_counter) finally: self._alias_lock.release() self.alias = alias | def __init__(self, table, alias=None): if hasattr(table, "sqlmeta"): tableName = table.sqlmeta.table else: tableName = table table = None Table.__init__(self, tableName) if alias is None: self._alias_lock.acquire() try: AliasTable._alias_counter += 1 alias = "%s_alias%d" % (tableName, AliasTable._alias_counter) finally... | 38,001 |
def __init__(self, table, alias=None): if hasattr(table, "sqlmeta"): table = table.sqlmeta.table self.q = AliasTable(table, alias) | def __init__(self, table, alias=None): self.q = AliasTable(table, alias) | 38,002 |
def createJoinTablesSQL(cls, connection=None): conn = connection or cls._connection sql = [] for join in cls._getJoinsToCreate(): if not getattr(join, 'createRelatedTable', True): # This join has requested not to be created continue sql.append(conn._SO_createJoinTableSQL(join)) return '\n'.join(sql) | def createJoinTablesSQL(cls, connection=None): conn = connection or cls._connection sql = [] for join in cls._getJoinsToCreate(): if not getattr(join, 'createRelatedTable', True): # This join has requested not to be created continue sql.append(conn._SO_createJoinTableSQL(join)) return '\n'.join(sql) | 38,003 |
def createIndexesSQL(cls, connection=None): conn = connection or cls._connection sql = [] for index in cls.sqlmeta.indexes: if not index: continue sql.append(conn.createIndexSQL(cls, index)) return '\n'.join(sql) | def createIndexesSQL(cls, connection=None): conn = connection or cls._connection sql = [] for index in cls.sqlmeta.indexes: if not index: continue sql.append(conn.createIndexSQL(cls, index)) return '\n'.join(sql) | 38,004 |
def __sqlrepr__(self, db): select = "SELECT %s" % ", ".join([sqlrepr(v, db) for v in self.items]) | def __sqlrepr__(self, db): select = "SELECT %s" % ", ".join([sqlrepr(v, db) for v in self.items]) | 38,005 |
def __init__(self, expr): self.expr = expr | def __init__(self, expr): self.expr = expr | 38,006 |
def __sqlrepr__(self, db): s = sqlrepr(self.expr, db) if db in ('postgres', 'mysql'): return s.replace('%', '\\%') else: return s.replace('%', '%%') | def __sqlrepr__(self, db): s = sqlrepr(self.expr, db) if db in ('postgres', 'mysql'): s = s.replace('%', '\\%') else: return s.replace('%', '%%') | 38,007 |
def __sqlrepr__(self, db): s = sqlrepr(self.expr, db) if db in ('postgres', 'mysql'): return s.replace('%', '\\%') else: return s.replace('%', '%%') | def __sqlrepr__(self, db): s = sqlrepr(self.expr, db) if db in ('postgres', 'mysql'): return s.replace('%', '\\%') else: return s.replace('%', '%%') | 38,008 |
def _SO_columnClause(self, soClass, kw): return ' '.join(['%s = %s' % (soClass._SO_columnDict[key].dbName, self.sqlrepr(value)) for key, value in kw.items()]) | def _SO_columnClause(self, soClass, kw): return ' AND '.join(['%s = %s' % (soClass._SO_columnDict[key].dbName, self.sqlrepr(value)) for key, value in kw.items()]) | 38,009 |
def addColumn(cls, columnDef, changeSchema=False, connection=None): post_funcs = [] cls.send(events.AddColumnSignal, cls.soClass, connection, columnDef.name, columnDef, changeSchema, post_funcs) sqlmeta = cls soClass = cls.soClass del cls column = columnDef.withClass(soClass) name = column.name assert name != 'id', ( "... | def addColumn(cls, columnDef, changeSchema=False, connection=None): post_funcs = [] cls.send(events.AddColumnSignal, cls.soClass, connection, columnDef.name, columnDef, changeSchema, post_funcs) sqlmeta = cls soClass = cls.soClass del cls column = columnDef.withClass(soClass) name = column.name assert name != 'id', ( "... | 38,010 |
def _create(self, id, **kw): | def _create(self, id, **kw): | 38,011 |
def __init__(self, dsn=None, host=None, port=None, db=None, user=None, password=None, usePygresql=False, unicodeCols=False, **kw): global psycopg, pgdb self.usePygresql = usePygresql if usePygresql: if pgdb is None: import pgdb self.module = pgdb else: if psycopg is None: try: import psycopg2 as psycopg except ImportEr... | def __init__(self, dsn=None, host=None, port=None, db=None, user=None, password=None, usePygresql=False, unicodeCols=False, **kw): global psycopg, pgdb self.usePygresql = usePygresql if usePygresql: if pgdb is None: import pgdb self.module = pgdb else: if psycopg is None: try: import psycopg2 as psycopg except ImportEr... | 38,012 |
def best_upgrade(self, current, dest, target_dbname): current_dir = os.path.join(self.base_dir(), current) if self.options.verbose > 1: print ('Looking in %s for upgraders' % self.shorten_filename(current_dir)) upgraders = [] for fn in os.listdir(current_dir): match = self.upgrade_regex.search(fn) if not match: if self... | def best_upgrade(self, current, dest, target_dbname): current_dir = os.path.join(self.base_dir(), current) if self.options.verbose > 1: print ('Looking in %s for upgraders' % self.shorten_filename(current_dir)) upgraders = [] for fn in os.listdir(current_dir): match = self.upgrade_regex.search(fn) if not match: if self... | 38,013 |
def _queryAddLimitOffset(self, query, start, end): # XXX Sybase doesn't support LIMIT return query | def if end: return "SET ROWCOUNT %i %s SET ROWCOUNT 0" % (end, query) _queryAddLimitOffset(self, if end: return "SET ROWCOUNT %i %s SET ROWCOUNT 0" % (end, query) query, if end: return "SET ROWCOUNT %i %s SET ROWCOUNT 0" % (end, query) start, if end: return "SET ROWCOUNT %i %s SET ROWCOUNT 0" % (end, query) end): if en... | 38,014 |
def _executeRetry(self, conn, cursor, query): while 1: try: if self.need_unicode: # For MysqlDB 1.2.1 and later, we go # encoding->unicode->charset (in the mysql db) myquery = unicode(query, self.encoding) return cursor.execute(myquery) else: return cursor.execute(query) except MySQLdb.OperationalError, e: if e.args[0]... | def _executeRetry(self, conn, cursor, query): for c in range(0, 3): try: if self.need_unicode: # For MysqlDB 1.2.1 and later, we go # encoding->unicode->charset (in the mysql db) myquery = unicode(query, self.encoding) return cursor.execute(myquery) else: return cursor.execute(query) except MySQLdb.Operatio... | 38,015 |
def _executeRetry(self, conn, cursor, query): while 1: try: if self.need_unicode: # For MysqlDB 1.2.1 and later, we go # encoding->unicode->charset (in the mysql db) myquery = unicode(query, self.encoding) return cursor.execute(myquery) else: return cursor.execute(query) except MySQLdb.OperationalError, e: if e.args[0]... | def _executeRetry(self, conn, cursor, query): while 1: try: if self.need_unicode: # For MysqlDB 1.2.1 and later, we go # encoding->unicode->charset (in the mysql db) myquery = unicode(query, self.encoding) return cursor.execute(myquery) else: return cursor.execute(query) except MySQLdb.OperationalError, e: if e.args[0]... | 38,016 |
def config_from_egg(self, egg_spec, warn_no_sqlobject=True): import pkg_resources pkg_resources.require(egg_spec) dist = pkg_resources.working_set.find(pkg_resources.Requirement(egg_spec)) if not dist.has_metadata('sqlobject.txt'): if warn_no_sqlobject: print 'No sqlobject.txt in %s egg info' % egg_spec return {} resul... | def config_from_egg(self, egg_spec, warn_no_sqlobject=True): import pkg_resources pkg_resources.require(egg_spec) dist = pkg_resources.working_set.find(pkg_resources.Requirement(egg_spec)) if not dist.has_metadata('sqlobject.txt'): if warn_no_sqlobject: print 'No sqlobject.txt in %s egg info' % egg_spec return None, {}... | 38,017 |
def config_from_egg(self, egg_spec, warn_no_sqlobject=True): import pkg_resources pkg_resources.require(egg_spec) dist = pkg_resources.working_set.find(pkg_resources.Requirement(egg_spec)) if not dist.has_metadata('sqlobject.txt'): if warn_no_sqlobject: print 'No sqlobject.txt in %s egg info' % egg_spec return {} resul... | def config_from_egg(self, egg_spec, warn_no_sqlobject=True): import pkg_resources pkg_resources.require(egg_spec) dist = pkg_resources.working_set.find(pkg_resources.Requirement(egg_spec)) if not dist.has_metadata('sqlobject.txt'): if warn_no_sqlobject: print 'No sqlobject.txt in %s egg info' % egg_spec return {} resul... | 38,018 |
def __init__(self, dsn=None, host=None, port=None, db=None, user=None, password=None, usePygresql=False, unicodeCols=False, **kw): global psycopg, pgdb self.usePygresql = usePygresql if usePygresql: if pgdb is None: import pgdb self.module = pgdb else: if psycopg is None: try: import psycopg2 as psycopg except ImportEr... | def __init__(self, dsn=None, host=None, port=None, db=None, user=None, password=None, usePygresql=False, unicodeCols=False, **kw): global psycopg, pgdb self.usePygresql = usePygresql if usePygresql: if pgdb is None: import pgdb self.module = pgdb else: if psycopg is None: try: import psycopg2 as psycopg except ImportEr... | 38,019 |
def _wrapper(self, *args, **kwargs): lock.acquire() return_value = fn(self, *args, **kwargs) lock.release() return return_value | def _wrapper(self, *args, **kwargs): lock.acquire() return_value = fn(self, *args, **kwargs) lock.release() return return_value | 38,020 |
def _queryInsertID(self, conn, table, idName, id, names, values): """Firebird uses 'generators' to create new ids for a table. The users needs to create a generator named GEN_<tablename> for each table this method to work.""" table = soInstance._table idName = soInstance._idName sequenceName = getattr(soInstance, '_idS... | def _queryInsertID(self, conn, soInstance, id, names, values): """Firebird uses 'generators' to create new ids for a table. The users needs to create a generator named GEN_<tablename> for each table this method to work.""" table = soInstance._table idName = soInstance._idName sequenceName = getattr(soInstance, '_idSequ... | 38,021 |
def main(): import unittest from getopt import getopt, GetoptError try: options, arguments = getopt(sys.argv[1:], "d:v", ["database=", "extra-verbose", "super-verbose", "inserts", "coverage"]) except GetoptError: usage(1) dbs = [] newArgs = [] doCoverage = False verbose = 0 for option, value in options: if option in... | def main(): import unittest from getopt import getopt, GetoptError try: options, arguments = getopt(sys.argv[1:], "d:v", ["database=", "extra-verbose", "super-verbose", "inserts", "coverage"]) except GetoptError: sys.exit("Usage: %s [-d|--database all|type] [-v[v]] [--extra-verbose|--super-verbose] [--inserts] [--cove... | 38,022 |
def get(cls, id, connection=None, selectResults=None): | def get(cls, id, connection=None, selectResults=None): | 38,023 |
def __init__(self, filename, autoCommit=1, **kw): global sqlite global using_sqlite2 if sqlite is None: try: from pysqlite2 import dbapi2 as sqlite using_sqlite2 = True except ImportError: import sqlite using_sqlite2 = False self.module = sqlite self.filename = filename # full path to sqlite-db-file self._memory = fil... | def__init__(self,filename,autoCommit=1,**kw):globalsqliteglobalusing_sqlite2ifsqliteisNone:try:frompysqlite2importdbapi2assqliteusing_sqlite2=TrueexceptImportError:importsqliteusing_sqlite2=Falseself.module=sqliteself.filename=filename#fullpathtosqlite-db-fileself._memory=filename==':memory:'ifself._memory:ifnotusing_s... | 38,024 |
def __init__(self, dbConnection): self._dbConnection = dbConnection self._connection = dbConnection.getConnection() self._dbConnection._setAutoCommit(self._connection, 0) self.cache = CacheSet(cache=dbConnection.doCache) self._obsolete = False | def __init__(self, dbConnection): self._dbConnection = dbConnection self._connection = dbConnection.getConnection() self._dbConnection._setAutoCommit(self._connection, 0) self.cache = CacheSet(cache=dbConnection.doCache) self._obsolete = False | 38,025 |
def _get_name(self): return kw['name'] | def _get_name(self): return kw['name'] | 38,026 |
def __init__(self, **kw): self.length = popKey(kw, 'length') self.varchar = popKey(kw, 'varchar', 'auto') self.char_binary = popKey(kw, 'char_binary', None) # A hack for MySQL if not self.length: assert self.varchar == 'auto' or not self.varchar, \ "Without a length strings are treated as TEXT, not varchar" self.varcha... | def __init__(self, **kw): self.length = popKey(kw, 'length') self.varchar = popKey(kw, 'varchar', 'auto') self.char_binary = popKey(kw, 'char_binary', None) # A hack for MySQL if not self.length: assert self.varchar == 'auto' or not self.varchar, \ "Without a length strings are treated as TEXT, not varchar" self.varcha... | 38,027 |
def __init__(self, **kw): foreignKey = kw['foreignKey'] style = kw['soClass'].sqlmeta.style if not kw.get('name'): kw['name'] = style.instanceAttrToIDAttr(style.pythonClassToAttr(foreignKey)) else: kw['origName'] = kw['name'] if not kw['name'].upper().endswith('ID'): kw['name'] = style.instanceAttrToIDAttr(kw['name']) ... | def __init__(self, **kw): foreignKey = kw['foreignKey'] style = kw['soClass'].sqlmeta.style if not kw.get('name'): kw['name'] = style.instanceAttrToIDAttr(style.pythonClassToAttr(foreignKey)) else: kw['origName'] = kw['name'] if not kw['name'].upper().endswith('ID'): kw['name'] = style.instanceAttrToIDAttr(kw['name']) ... | 38,028 |
def __init__(self, foreignKey=None, **kw): KeyCol.__init__(self, foreignKey=foreignKey, **kw) | def __init__(self, foreignKey=None, **kw): KeyCol.__init__(self, foreignKey=foreignKey, **kw) | 38,029 |
def __init__(self, **kw): self.enumValues = popKey(kw, 'enumValues', None) assert self.enumValues is not None, \ 'You must provide an enumValues keyword argument' SOCol.__init__(self, **kw) | def __init__(self, **kw): self.enumValues = popKey(kw, 'enumValues', None) assert self.enumValues is not None, \ 'You must provide an enumValues keyword argument' SOCol.__init__(self, **kw) | 38,030 |
def __init__(self, **kw): datetimeFormat = popKey(kw, 'datetimeFormat') if datetimeFormat: self.datetimeFormat = datetimeFormat SOCol.__init__(self, **kw) | def __init__(self, **kw): datetimeFormat = popKey(kw, 'datetimeFormat') if datetimeFormat: self.datetimeFormat = datetimeFormat SOCol.__init__(self, **kw) | 38,031 |
def __init__(self, **kw): dateFormat = popKey(kw, 'dateFormat') if dateFormat: self.dateFormat = dateFormat SOCol.__init__(self, **kw) | def __init__(self, **kw): dateFormat = popKey(kw, 'dateFormat') if dateFormat: self.dateFormat = dateFormat SOCol.__init__(self, **kw) | 38,032 |
def __init__(self, **kw): timeFormat = popKey(kw, 'timeFormat') if timeFormat: self.timeFormat = timeFormat SOCol.__init__(self, **kw) | def __init__(self, **kw): timeFormat = popKey(kw, 'timeFormat') if timeFormat: self.timeFormat = timeFormat SOCol.__init__(self, **kw) | 38,033 |
def __init__(self, **kw): self.size = popKey(kw, 'size', NoDefault) assert self.size is not NoDefault, \ "You must give a size argument" self.precision = popKey(kw, 'precision', NoDefault) assert self.precision is not NoDefault, \ "You must give a precision argument" SOCol.__init__(self, **kw) | def __init__(self, **kw): self.size = popKey(kw, 'size', NoDefault) assert self.size is not NoDefault, \ "You must give a size argument" self.precision = popKey(kw, 'precision', NoDefault) assert self.precision is not NoDefault, \ "You must give a precision argument" SOCol.__init__(self, **kw) | 38,034 |
def __init__(self, **kw): pushKey(kw, 'size', 10) pushKey(kw, 'precision', 2) SODecimalCol.__init__(self, **kw) | def __init__(self, **kw): pushKey(kw, 'size', 10) pushKey(kw, 'precision', 2) SODecimalCol.__init__(self, **kw) | 38,035 |
def __init__(self, **kw): self.pickleProtocol = popKey(kw, 'pickleProtocol', 1) SOBLOBCol.__init__(self, **kw) | def __init__(self, **kw): self.pickleProtocol = popKey(kw, 'pickleProtocol', 1) SOBLOBCol.__init__(self, **kw) | 38,036 |
def fromPython(self, value, state): if value: return sqlbuilder.TRUE else: return sqlbuilder.FALSE | def fromPython(self, value, state): if value is None: return None elif value: return sqlbuilder.TRUE else: return sqlbuilder.FALSE | 38,037 |
def toPython(self, value, state): if not value: return sqlbuilder.FALSE else: return sqlbuilder.TRUE | def toPython(self, value, state): if value is None: return None elif not value: return sqlbuilder.FALSE else: return sqlbuilder.TRUE | 38,038 |
def __init__(self, dsn=None, host=None, port=None, db=None, user=None, passwd=None, usePygresql=False, **kw): global psycopg, pgdb self.usePygresql = usePygresql if usePygresql: if pgdb is None: import pgdb self.module = pgdb else: if psycopg is None: import psycopg self.module = psycopg | def __init__(self, dsn=None, host=None, port=None, db=None, user=None, passwd=None, usePygresql=False, unicodeCols=False, **kw): global psycopg, pgdb self.usePygresql = usePygresql if usePygresql: if pgdb is None: import pgdb self.module = pgdb else: if psycopg is None: import psycopg self.module = psycopg | 38,039 |
def _warn(msg): import warnings warnings.warn(msg, DeprecationWarning, stacklevel=2) | def _warn(msg): import warnings warnings.warn(msg, DeprecationWarning, stacklevel=2) | 38,040 |
def FirebirdConnection(*args, **kw): _warn('FirebirdConnection is deprecated; use connectionForURI("firebird://...") or "from sqlobject.firebird import builder; FirebirdConnection = builder()"') _firebird.builder()(*args, **kw) | def FirebirdConnection(*args, **kw): _warn('FirebirdConnection is deprecated; use connectionForURI("firebird://...") or "from sqlobject.firebird import builder; FirebirdConnection = builder()"') return _firebird.builder()(*args, **kw) | 38,041 |
def FirebirdConnection(*args, **kw): _warn('FirebirdConnection is deprecated; use connectionForURI("firebird://...") or "from sqlobject.firebird import builder; FirebirdConnection = builder()"') _firebird.builder()(*args, **kw) | def FirebirdConnection(*args, **kw): _warn('FirebirdConnection is deprecated; use connectionForURI("firebird://...") or "from sqlobject.firebird import builder; FirebirdConnection = builder()"') _firebird.builder()(*args, **kw) | 38,042 |
def MySQLConnection(*args, **kw): _warn('MySQLConnection is deprecated; use connectionForURI("mysql://...") or "from sqlobject.mysql import builder; MySQLConnection = builder()"') _mysql.builder()(*args, **kw) | def MySQLConnection(*args, **kw): _warn('MySQLConnection is deprecated; use connectionForURI("mysql://...") or "from sqlobject.mysql import builder; MySQLConnection = builder()"') return _mysql.builder()(*args, **kw) | 38,043 |
def MySQLConnection(*args, **kw): _warn('MySQLConnection is deprecated; use connectionForURI("mysql://...") or "from sqlobject.mysql import builder; MySQLConnection = builder()"') _mysql.builder()(*args, **kw) | def MySQLConnection(*args, **kw): _warn('MySQLConnection is deprecated; use connectionForURI("mysql://...") or "from sqlobject.mysql import builder; MySQLConnection = builder()"') _mysql.builder()(*args, **kw) | 38,044 |
def PostgresConnection(*args, **kw): _warn('PostgresConnection is deprecated; use connectionForURI("postgres://...") or "from sqlobject.postgres import builder; PostgresConnection = builder()"') _postgres.builder()(*args, **kw) | def PostgresConnection(*args, **kw): _warn('PostgresConnection is deprecated; use connectionForURI("postgres://...") or "from sqlobject.postgres import builder; PostgresConnection = builder()"') return _postgres.builder()(*args, **kw) | 38,045 |
def PostgresConnection(*args, **kw): _warn('PostgresConnection is deprecated; use connectionForURI("postgres://...") or "from sqlobject.postgres import builder; PostgresConnection = builder()"') _postgres.builder()(*args, **kw) | def PostgresConnection(*args, **kw): _warn('PostgresConnection is deprecated; use connectionForURI("postgres://...") or "from sqlobject.postgres import builder; PostgresConnection = builder()"') _postgres.builder()(*args, **kw) | 38,046 |
def SQLiteConnection(*args, **kw): _warn('SQLiteConnection is deprecated; use connectionForURI("sqlite://...") or "from sqlobject.sqlite import builder; SQLiteConnection = builder()"') _sqlite.builder()(*args, **kw) | def SQLiteConnection(*args, **kw): _warn('SQLiteConnection is deprecated; use connectionForURI("sqlite://...") or "from sqlobject.sqlite import builder; SQLiteConnection = builder()"') return _sqlite.builder()(*args, **kw) | 38,047 |
def SQLiteConnection(*args, **kw): _warn('SQLiteConnection is deprecated; use connectionForURI("sqlite://...") or "from sqlobject.sqlite import builder; SQLiteConnection = builder()"') _sqlite.builder()(*args, **kw) | def SQLiteConnection(*args, **kw): _warn('SQLiteConnection is deprecated; use connectionForURI("sqlite://...") or "from sqlobject.sqlite import builder; SQLiteConnection = builder()"') _sqlite.builder()(*args, **kw) | 38,048 |
def DBMConnection(*args, **kw): _warn('DBMConnection is deprecated; use connectionForURI("dbm://...") or "from sqlobject.dbm import builder; DBMConnection = builder()"') _dbm.builder()(*args, **kw) | def DBMConnection(*args, **kw): _warn('DBMConnection is deprecated; use connectionForURI("dbm://...") or "from sqlobject.dbm import builder; DBMConnection = builder()"') return _dbm.builder()(*args, **kw) | 38,049 |
def DBMConnection(*args, **kw): _warn('DBMConnection is deprecated; use connectionForURI("dbm://...") or "from sqlobject.dbm import builder; DBMConnection = builder()"') _dbm.builder()(*args, **kw) | def DBMConnection(*args, **kw): _warn('DBMConnection is deprecated; use connectionForURI("dbm://...") or "from sqlobject.dbm import builder; DBMConnection = builder()"') _dbm.builder()(*args, **kw) | 38,050 |
def SybaseConnection(*args, **kw): _warn('SybaseConnection is deprecated; use connectionForURI("sybase://...") or "from sqlobject.sybase import builder; SybaseConnection = builder()"') _sybase.builder()(*args, **kw) | def SybaseConnection(*args, **kw): _warn('SybaseConnection is deprecated; use connectionForURI("sybase://...") or "from sqlobject.sybase import builder; SybaseConnection = builder()"') return _sybase.builder()(*args, **kw) | 38,051 |
def SybaseConnection(*args, **kw): _warn('SybaseConnection is deprecated; use connectionForURI("sybase://...") or "from sqlobject.sybase import builder; SybaseConnection = builder()"') _sybase.builder()(*args, **kw) | def SybaseConnection(*args, **kw): _warn('SybaseConnection is deprecated; use connectionForURI("sybase://...") or "from sqlobject.sybase import builder; SybaseConnection = builder()"') _sybase.builder()(*args, **kw) | 38,052 |
def __repr__(self): if self: return 'TRUE' else: return 'FALSE' | def __repr__(self): if self: return 'TRUE' else: return 'FALSE' | 38,053 |
def __init__(self, desc, obj, col, value, *args): self.desc = desc self.col = col | def __init__(self, desc, obj, col, value, *args): self.desc = desc self.col = col | 38,054 |
def __call__(self, obj, col, value): if value not in self.list: raise BadValue("accepts only values in %s" % self.list, obj, col, value) | def __call__(self, obj, col, value): if value not in self.list: raise BadValue("accepts only values in %s" % repr(self.list), obj, col, value) | 38,055 |
(SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d | (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d | 38,056 |
def DateTimeConverter(value, db): return value.strftime("'%Y-%m-%d %H:%M:%s'") | def DateTimeConverter(value, db): return value.strftime("'%Y-%m-%d %H:%M:%s'") | 38,057 |
def TimeConverter(value, db): return value.strftime("'%H:%M:%s'") | def TimeConverter(value, db): return value.strftime("'%H:%M:%s'") | 38,058 |
def __init__(self, makeDefault=False, **kw): SOMultipleJoin.__init__(self, **kw) self.makeDefault = makeDefault | def __init__(self, **kw): self.makeDefault = popKey(kw, 'makeDefault', False) SOMultipleJoin.__init__(self, **kw) self.makeDefault = makeDefault | 38,059 |
def __init__(self, makeDefault=False, **kw): SOMultipleJoin.__init__(self, **kw) self.makeDefault = makeDefault | def __init__(self, makeDefault=False, **kw): SOMultipleJoin.__init__(self, **kw) self.makeDefault = makeDefault | 38,060 |
def addColumn(cls, columnDef, changeSchema=False, connection=None): post_funcs = [] cls.send(events.AddColumnSignal, cls.soClass, connection, columnDef.name, columnDef, changeSchema, post_funcs) sqlmeta = cls soClass = cls.soClass del cls column = columnDef.withClass(soClass) name = column.name assert name != 'id', ( "... | def addColumn(cls, columnDef, changeSchema=False, connection=None): post_funcs = [] cls.send(events.AddColumnSignal, cls.soClass, connection, columnDef.name, columnDef, changeSchema, post_funcs) sqlmeta = cls soClass = cls.soClass del cls column = columnDef.withClass(soClass) name = column.name assert name != 'id', ( "... | 38,061 |
def __init__(self, name, soClass, dbName=None, default=NoDefault, foreignKey=None, alternateID=False, alternateMethodName=None, constraints=None, notNull=NoDefault, notNone=NoDefault, unique=NoDefault, sqlType=None, columnDef=None, validator=None, immutable=False, cascade=None, lazy=False, noCache=False, forceDBName=Fa... | def __init__(self, name, soClass, dbName=None, default=NoDefault, foreignKey=None, alternateID=False, alternateMethodName=None, constraints=None, notNull=NoDefault, notNone=NoDefault, unique=NoDefault, sqlType=None, columnDef=None, validator=None, immutable=False, cascade=None, lazy=False, noCache=False, forceDBName=Fa... | 38,062 |
def postgresCreateSQL(self): sql = SOKeyCol.postgresCreateSQL(self) other = findClass(self.foreignKey) tName = other.sqlmeta.table idName = other.sqlmeta.idName if self.cascade is not None: if self.cascade == 'null': action = 'ON DELETE SET NULL' elif self.cascade: action = 'ON DELETE CASCADE' else: action = 'ON DELETE... | def postgresCreateSQL(self): sql = SOKeyCol.postgresCreateSQL(self) print [self, self.soClass] other = findClass(self.foreignKey, self.soClass.sqlmeta.registry) tName = other.sqlmeta.table idName = other.sqlmeta.idName if self.cascade is not None: if self.cascade == 'null': action = 'ON DELETE SET NULL' elif self.casca... | 38,063 |
def __init__(self, sourceClass, clause, clauseTables=None, **ops): if clause is None or isinstance(clause, str) and clause == 'all': clause = sqlbuilder.SQLTrueClause tablesDict = sqlbuilder.tablesUsedDict(clause) tablesDict[sourceClass.sqlmeta.table] = 1 orderBy = ops.get('orderBy') if orderBy and not isinstance(order... | def __init__(self, sourceClass, clause, clauseTables=None, **ops): if clause is None or isinstance(clause, str) and clause == 'all': clause = sqlbuilder.SQLTrueClause tablesDict = sqlbuilder.tablesUsedDict(clause) tablesDict[sourceClass.sqlmeta.table] = 1 orderBy = ops.get('orderBy') if orderBy and not isinstance(order... | 38,064 |
def __init__(self, sourceClass, clause, clauseTables=None, **ops): if clause is None or isinstance(clause, str) and clause == 'all': clause = sqlbuilder.SQLTrueClause tablesDict = sqlbuilder.tablesUsedDict(clause) tablesDict[sourceClass.sqlmeta.table] = 1 orderBy = ops.get('orderBy') if orderBy and not isinstance(order... | def __init__(self, sourceClass, clause, clauseTables=None, **ops): if clause is None or isinstance(clause, str) and clause == 'all': clause = sqlbuilder.SQLTrueClause tablesDict = sqlbuilder.tablesUsedDict(clause) tablesDict[sourceClass.sqlmeta.table] = 1 orderBy = ops.get('orderBy') if orderBy and not isinstance(order... | 38,065 |
def __init__(self, db, user, password='', host='localhost', port=None, **kw): global MySQLdb if MySQLdb is None: import MySQLdb self.module = MySQLdb self.host = host self.port = port self.db = db self.user = user self.password = password if kw.has_key('client_encoding'): self.client_encoding = col.popKey(kw, 'client_e... | def __init__(self, db, user, password='', host='localhost', port=None, **kw): global MySQLdb if MySQLdb is None: import MySQLdb self.module = MySQLdb self.host = host self.port = port self.db = db self.user = user self.password = password if kw.has_key('client_encoding'): self.client_encoding = col.popKey(kw, 'client_e... | 38,066 |
def set(self, **kw): # set() is used to update multiple values at once, # potentially with one SQL statement if possible. | def set(self, **kw): # set() is used to update multiple values at once, # potentially with one SQL statement if possible. | 38,067 |
def __init__(self, db, user, passwd='', host='localhost', **kw): global MySQLdb if MySQLdb is None: import MySQLdb self.module = MySQLdb self.host = host self.db = db self.user = user self.password = passwd DBAPI.__init__(self, **kw) | def __init__(self, db, user, passwd='', host='localhost', port=None, **kw): global MySQLdb if MySQLdb is None: import MySQLdb self.module = MySQLdb self.host = host self.db = db self.user = user self.password = passwd DBAPI.__init__(self, **kw) | 38,068 |
def makeConnection(self): return MySQLdb.connect(host=self.host, db=self.db, user=self.user, passwd=self.password) | def makeConnection(self): return MySQLdb.connect(host=self.host, port=self.port, db=self.db, user=self.user, passwd=self.password) | 38,069 |
def _reprItems(self): items = [] for col in self.sqlmeta.columnList: value = getattr(self, col.name) r = repr(value) if len(r) > 20: value = r[:17] + "..." + r[-1] items.append((col.name, getattr(self, col.name))) return items | def _reprItems(self): items = [] for col in self.sqlmeta.columnList: value = getattr(self, col.name) r = repr(value) if len(r) > 20: value = r[:17] + "..." + r[-1] items.append((col.name, value)) return items | 38,070 |
def setupClass(soClasses): """ Makes sure the classes have a corresponding and correct table. This won't recreate the table if it already exists. It will check that the table is properly defined (in case you change your table definition). You can provide a single class or a list of classes; if a list then classes wil... | def setupClass(soClasses): """ Makes sure the classes have a corresponding and correct table. This won't recreate the table if it already exists. It will check that the table is properly defined (in case you change your table definition). You can provide a single class or a list of classes; if a list then classes wil... | 38,071 |
def delColumn(self, tableName, column): self.query('ALTER TABLE %s DROP COLUMN %s' % (tableName, column.dbName)) | def delColumn(self, tableName, column): self.query('ALTER TABLE %s DROP COLUMN %s' % (tableName, column.dbName)) | 38,072 |
def columnsFromSchema(self, tableName, soClass): colData = self.queryAll(self.SHOW_COLUMNS % tableName) results = [] for field, t, nullAllowed, key, default, extra in colData: if field == 'id': continue colClass, kw = self.guessClass(t) kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field) kw['notNone'] = not ... | def columnsFromSchema(self, tableName, soClass): colData = self.queryAll(self.SHOW_COLUMNS % tableName) results = [] for field, t, nullAllowed, default in colData: if field == 'id': continue colClass, kw = self.guessClass(t) kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field) kw['notNone'] = not nullAllowed ... | 38,073 |
def createTableSQL(cls, createJoinTables=True, createIndexes=True, connection=None): conn = connection or cls._connection sql, constraints = conn.createTableSQL(cls) if createJoinTables: sql += '\n' + cls.createJoinTablesSQL(connection=conn) if createIndexes: sql += '\n' + cls.createIndexesSQL(connection=conn) return s... | def createTableSQL(cls, createJoinTables=True, createIndexes=True, connection=None): conn = connection or cls._connection sql, constraints = conn.createTableSQL(cls) if createJoinTables: join_sql = cls.createJoinTablesSQL(connection=conn) if join_sql: sql = ';\n' + join_sql if createIndexes: sql += '\n' + cls.createInd... | 38,074 |
def createTableSQL(cls, createJoinTables=True, createIndexes=True, connection=None): conn = connection or cls._connection sql, constraints = conn.createTableSQL(cls) if createJoinTables: sql += '\n' + cls.createJoinTablesSQL(connection=conn) if createIndexes: sql += '\n' + cls.createIndexesSQL(connection=conn) return s... | def createTableSQL(cls, createJoinTables=True, createIndexes=True, connection=None): conn = connection or cls._connection sql, constraints = conn.createTableSQL(cls) if createJoinTables: sql += '\n' + cls.createJoinTablesSQL(connection=conn) if createIndexes: index_sql = cls.createIndexesSQL(connection=conn) if index_s... | 38,075 |
def tableExists(self, tableName): for (table,) in self.queryAll('SHOW TABLES'): if table.lower() == tableName.lower(): return True return False | def tableExists(self, tableName): for (table,) in self.queryAll('SHOW TABLES'): if table.lower() == tableName.lower(): return True return False | 38,076 |
def test_dateTime(): setupClass(DateTime1) _now = now() dt1 = DateTime1(col1=_now, col2=_now) assert isinstance(dt1.col1, date) assert isinstance(dt1.col2, datetime) | def test_dateTime(): setupClass(DateTime1) _now = now() dt1 = DateTime1(col1=_now, col2=_now) assert isinstance(dt1.col1, date) assert isinstance(dt1.col2, datetime) | 38,077 |
def test_dateTime(): setupClass(DateTime1) _now = now() dt1 = DateTime1(col1=_now, col2=_now) assert isinstance(dt1.col1, date) assert isinstance(dt1.col2, datetime) | def test_dateTime(): setupClass(DateTime1) _now = now() dt1 = DateTime1(col1=_now, col2=_now) assert isinstance(dt1.col1, date) assert isinstance(dt1.col2, datetime) | 38,078 |
def test_dateTime(): setupClass(DateTime1) _now = now() dt1 = DateTime1(col1=_now, col2=_now) assert isinstance(dt1.col1, date) assert isinstance(dt1.col2, datetime) | def test_dateTime(): setupClass(DateTime1) _now = now() dt1 = DateTime1(col1=_now, col2=_now) assert isinstance(dt1.col1, date) assert isinstance(dt1.col2, datetime) | 38,079 |
def test_mxDateTime(): setupClass(DateTime2) _now = now() dt2 = DateTime2(col1=_now, col2=_now) assert isinstance(dt2.col1, col.DateTimeType) assert isinstance(dt2.col2, col.DateTimeType) | def test_mxDateTime(): setupClass(DateTime2) _now = now() dt2 = DateTime2(col1=_now, col2=_now) assert isinstance(dt2.col1, col.DateTimeType) assert isinstance(dt2.col2, col.DateTimeType) | 38,080 |
def setDeprecationLevel(warning=1, exception=None): """ Set the deprecation level for SQLObject. Low levels are more actively being deprecated. Any warning at a level at or below ``warning`` will give a warning. Any warning at a level at or below ``exception`` will give an exception. You can use a higher ``exceptio... | def setDeprecationLevel(warning=1, exception=None): """ Set the deprecation level for SQLObject. Low levels are more actively being deprecated. Any warning at a level at or below ``warning`` will give a warning. Any warning at a level at or below ``exception`` will give an exception. You can use a higher ``exceptio... | 38,081 |
def __init__(self, dsn=None, host=None, port=None, db=None, user=None, passwd=None, usePygresql=False, **kw): global psycopg, pgdb if usePygresql: if pgdb is None: import pgdb self.module = pgdb else: if psycopg is None: import psycopg self.module = psycopg | def __init__(self, dsn=None, host=None, port=None, db=None, user=None, passwd=None, usePygresql=False, **kw): global psycopg, pgdb if usePygresql: if pgdb is None: import pgdb self.module = pgdb else: if psycopg is None: import psycopg self.module = psycopg | 38,082 |
def _warn(msg): import warnings warnings.warn(msg, warnings.DeprecationWarning, stacklevel=2) | def _warn(msg): import warnings warnings.warn(msg, DeprecationWarning, stacklevel=2) | 38,083 |
def doInTransaction(self, func, *args, **kw): """ This routine can be used to run a function in a transaction, rolling the transaction back if any exception is raised from that function, and committing otherwise. Use like:: | def doInTransaction(self, func, *args, **kw): """ This routine can be used to run a function in a transaction, rolling the transaction back if any exception is raised from that function, and committing otherwise. Use like:: | 38,084 |
def pushKey(kw, name, value): if not kw.has_key(name): kw[name] = value | def pushKey(kw, name, value): if not kw.has_key(name): kw[name] = value | 38,085 |
def allIDs(self): if self.doCache: all = self.cache.keys() else: all = [] for id, value in self.expiredCache: if value(): all.append(id) return all | def allIDs(self): if self.doCache: all = self.cache.keys() else: all = [] for id, value in self.expiredCache.items(): if value(): all.append(id) return all | 38,086 |
def delColumn(sqlmeta, column, changeSchema=False, connection=None): soClass = sqlmeta.soClass if isinstance(column, str): column = sqlmeta.columns[column] if isinstance(column, col.Col): for c in sqlmeta.columns.values(): if column is c.columnDef: column = c break else: raise IndexError( "Column with definition %r not... | def delColumn(cls, column, changeSchema=False, connection=None): sqlmeta = cls soClass = sqlmeta.soClass if isinstance(column, str): column = sqlmeta.columns[column] if isinstance(column, col.Col): for c in sqlmeta.columns.values(): if column is c.columnDef: column = c break else: raise IndexError( "Column with definit... | 38,087 |
def createEmptyDatabase(self): # We have to connect to *some* database, so we'll connect to # template1, which is a common open database. # @@: This doesn't use self.use_dsn or self.dsn_dict if self.usePygresql: dsn = '%s:template1:%s:%s' % ( self.host or '', self.user or '', self.password or '') else: dsn = 'dbname=te... | def createEmptyDatabase(self): # We have to connect to *some* database, so we'll connect to # template1, which is a common open database. # @@: This doesn't use self.use_dsn or self.dsn_dict if self.usePygresql: dsn = '%s:template1:%s:%s' % ( self.host or '', self.user or '', self.password or '') else: dsn = 'dbname=te... | 38,088 |
def __init__(self, filename, autoCommit=1, **kw): global sqlite if sqlite is None: import sqlite self.module = sqlite self.filename = filename # full path to sqlite-db-file if not autoCommit and not kw.has_key('pool'): # Pooling doesn't work with transactions... kw['pool'] = 0 # use only one connection for sqlite - su... | def opts = {'autocommit': autoCommit} if 'encoding' in kw: opts['encoding'] = popKey(kw, 'encoding') if 'mode' in kw: opts['mode'] = int(popKey(kw, 'mode'), 0) if 'timeout' in kw: opts['timeout'] = float(popKey(kw, 'timeout')) __init__(self, opts = {'autocommit': autoCommit} if 'encoding' in kw: opts['encoding'] = pop... | 38,089 |
def __init__(self, filename, autoCommit=1, **kw): global sqlite if sqlite is None: import sqlite self.module = sqlite self.filename = filename # full path to sqlite-db-file if not autoCommit and not kw.has_key('pool'): # Pooling doesn't work with transactions... kw['pool'] = 0 # use only one connection for sqlite - su... | def __init__(self, filename, autoCommit=1, **kw): global sqlite if sqlite is None: import sqlite self.module = sqlite self.filename = filename # full path to sqlite-db-file if not autoCommit and not kw.has_key('pool'): # Pooling doesn't work with transactions... kw['pool'] = 0 # use only one connection for sqlite - su... | 38,090 |
def __init__(self, db, user, password='', host='localhost', port=None, **kw): global MySQLdb if MySQLdb is None: import MySQLdb self.module = MySQLdb self.host = host self.port = port self.db = db self.user = user self.password = password if kw.has_key('client_encoding'): self.client_encoding = col.popKey(kw, 'client_e... | def __init__(self, db, user, password='', host='localhost', port=None, **kw): global MySQLdb if MySQLdb is None: import MySQLdb self.module = MySQLdb self.host = host self.port = port self.db = db self.user = user self.password = password if kw.has_key('client_encoding'): self.client_encoding = col.popKey(kw, 'client_e... | 38,091 |
def _executeRetry(self, conn, cursor, query): while 1: try: return cursor.execute(query) except MySQLdb.OperationalError, e: if e.args[0] == 2013: # SERVER_LOST error if self.debug: self.printDebug(conn, str(e), 'ERROR') else: raise | def _executeRetry(self, conn, cursor, query): while 1: try: if self.need_unicode: myquery = unicode(query, self.encoding) return cursor.execute(myquery) else: return cursor.execute(query) except MySQLdb.OperationalError, e: if e.args[0] == 2013: # SERVER_LOST error if self.debug: self.printDebug(conn, str(e), 'ERROR'... | 38,092 |
def test_ack(self): """ Test basic ack/recover behaviour """ channel = self.channel channel.queue_declare(queue="test-ack-queue") reply = channel.basic_consume(queue="test-ack-queue", no_ack=False) queue = self.client.queue(reply.consumer_tag) | def test_ack(self): """ Test basic ack/recover behaviour """ channel = self.channel channel.queue_declare(queue="test-ack-queue", exclusive=True) reply = channel.basic_consume(queue="test-ack-queue", no_ack=False) queue = self.client.queue(reply.consumer_tag) | 38,093 |
def test_recover_requeue(self): """ Test requeing on recovery """ channel = self.channel channel.queue_declare(queue="test-requeue") subscription = channel.basic_consume(queue="test-requeue", no_ack=False) queue = self.client.queue(subscription.consumer_tag) | def test_recover_requeue(self): """ Test requeing on recovery """ channel = self.channel channel.queue_declare(queue="test-requeue", exclusive=True) subscription = channel.basic_consume(queue="test-requeue", no_ack=False) queue = self.client.queue(subscription.consumer_tag) | 38,094 |
def test_consume_no_local(self): """ Test that the no_local flag is honoured in the consume method """ channel = self.channel #setup, declare two queues: channel.queue_declare(queue="test-queue-1a", exclusive=True) channel.queue_declare(queue="test-queue-1b", exclusive=True) #establish two consumers one of which exclud... | def test_consume_no_local(self): """ Test that the no_local flag is honoured in the consume method """ channel = self.channel #setup, declare two queues: channel.queue_declare(queue="test-queue-1a", exclusive=True) channel.queue_declare(queue="test-queue-1b", exclusive=True) #establish two consumers one of which exclud... | 38,095 |
def makename(oldname): name = ""; nextBig = True; for x in oldname: if x == '_': nextBig = True; else: if nextBig: name += x.upper(); nextBig = False; else: name += x.lower(); return name; | def makename(oldname): name = ""; nextBig = True; for x in oldname: if x == '_': nextBig = True; else: if nextBig: name += x.upper(); nextBig = False; else: name += x.lower(); return name; | 38,096 |
def makename(oldname): name = ""; nextBig = True; for x in oldname: if x == '_': nextBig = True; else: if nextBig: name += x.upper(); nextBig = False; else: name += x.lower(); return name; | def makename(oldname): name = ""; nextBig = True; for x in oldname: if x == '_': nextBig = True; else: if nextBig: name += x.upper(); nextBig = False; else: name += x.lower(); return name; | 38,097 |
def makename(oldname): name = ""; nextBig = True; for x in oldname: if x == '_': nextBig = True; else: if nextBig: name += x.upper(); nextBig = False; else: name += x.lower(); return name; | def makename(oldname): name = ""; nextBig = True; for x in oldname: if x == '_': nextBig = True; else: if nextBig: name += x.upper(); nextBig = False; else: name += x.lower(); return name; | 38,098 |
def __init__(self,ref=None,kind=None): | def __init__(self,ref=None,kind=None): | 38,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.