Package gluon :: Module dal :: Class GoogleDatastoreAdapter
[hide private]
[frames] | no frames]

Class GoogleDatastoreAdapter

source code

    object --+            
             |            
ConnectionPool --+        
                 |        
       BaseAdapter --+    
                     |    
          NoSQLAdapter --+
                         |
                        GoogleDatastoreAdapter

NDB:

You can enable NDB by using adapter_args:

db = DAL('google:datastore', adapter_args={'ndb_settings':ndb_settings, 'use_ndb':True})

ndb_settings is optional and can be used for per model caching settings. It must be a dict in this form: ndb_settings = {<table_name>:{<variable_name>:<variable_value>}} See: https://developers.google.com/appengine/docs/python/ndb/cache

Nested Classes [hide private]

Inherited from BaseAdapter: __metaclass__

Instance Methods [hide private]
 
reconnect(*args, **kwargs)
this function defines: self.connection and self.cursor (iff cursor is True) if self.pool_size>0 it will try pull the connection from the pool if the connection is not active (closed by db server) it will loop if not self.pool_size or no active connections in pool makes a new one
source code
 
file_exists(self, filename)
to be used ONLY for files that on GAE may not be on filesystem
source code
 
file_open(self, filename, mode='rb', lock=True)
to be used ONLY for files that on GAE may not be on filesystem
source code
 
file_close(self, fileobj)
to be used ONLY for files that on GAE may not be on filesystem
source code
 
__init__(self, db, uri, pool_size=0, folder=None, db_codec='UTF-8', credential_decoder=<function IDENTITY at 0x334cd70>, driver_args={}, adapter_args={}, do_connect=True, after_connection=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
parse_id(self, value, field_type) source code
 
create_table(self, table, migrate=True, fake_migrate=False, polymodel=None) source code
 
expand(self, expression, field_type=None) source code
 
AND(self, first, second) source code
 
EQ(self, first, second=None) source code
 
NE(self, first, second=None) source code
 
LT(self, first, second=None) source code
 
LE(self, first, second=None) source code
 
GT(self, first, second=None) source code
 
GE(self, first, second=None) source code
 
INVERT(self, first) source code
 
COMMA(self, first, second) source code
 
BELONGS(self, first, second=None) source code
 
CONTAINS(self, first, second, case_sensitive=False) source code
 
NOT(self, first) source code
 
truncate(self, table, mode) source code
 
filter(self, query, tableobj, prop, op, value) source code
 
select_raw(self, query, fields=None, attributes=None) source code
 
select(self, query, fields, attributes)
This is the GAE version of select.
source code
 
parse_list_integers(self, value, field_type) source code
 
parse_list_strings(self, value, field_type) source code
 
count(self, query, distinct=None, limit=None) source code
 
delete(self, tablename, query)
This function was changed on 2010-05-04 because according to http://code.google.com/p/googleappengine/issues/detail?id=3119 GAE no longer supports deleting more than 1000 records.
source code
 
update(self, tablename, query, update_fields) source code
 
insert(self, table, fields) source code
 
bulk_insert(self, table, items) source code

Inherited from NoSQLAdapter: ADD, AGGREGATE, AS, DIV, ENDSWITH, EXTRACT, ILIKE, LEFT_JOIN, LENGTH, LOWER, MUL, ON, OR, PRIMARY_KEY, RANDOM, STARTSWITH, SUB, SUBSTRING, UPPER, alias, close_connection, commit, commit_prepared, concat_add, constraint_name, create_sequence_and_triggers, distributed_transaction_begin, drop, execute, id_query, lastrowid, log_execute, migrate_table, prepare, represent, represent_exceptions, rollback, rollback_prepared, rowslice

Inherited from NoSQLAdapter (private): _count, _delete, _insert, _select, _update

Inherited from BaseAdapter: ALLOW_NULL, CASE, CAST, COALESCE, COALESCE_ZERO, CONCAT, COUNT, EPOCH, JOIN, LIKE, MOD, NOT_NULL, RAW, REGEXP, REPLACE, adapt, build_parsemap, common_filter, connector, expand_all, file_delete, find_driver, get_table, isOperationalError, isProgrammingError, is_numerical_type, log, parse, parse_blob, parse_boolean, parse_date, parse_datetime, parse_decimal, parse_double, parse_integer, parse_json, parse_list_references, parse_reference, parse_time, parse_value, save_dbt, select_limitby, sequence_name, smart_adapt, sqlsafe_field, sqlsafe_table, table_alias, tables, trigger_name, varquote

Inherited from ConnectionPool: after_connection, after_connection_hook, close, find_or_make_work_folder

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]

Inherited from NoSQLAdapter: to_unicode

Inherited from ConnectionPool: close_all_instances, set_folder

Class Variables [hide private]
  uploads_in_blob = True
  types = {}
  REGEX_NAMESPACE = re.compile(r'.*://(?P<namespace>.+)')
  GAE_FILTER_OPTIONS = {'=': lambda q, t, p, v: q.filter(getattr...

Inherited from NoSQLAdapter: QUOTE_TEMPLATE, can_select_for_update

Inherited from BaseAdapter: FALSE, TRUE, T_SEP, commit_on_alter_table, connection, dbpath, driver, driver_name, drivers, folder, native_json, support_distributed_transaction

Inherited from ConnectionPool: POOLS, check_active_connection

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

reconnect(*args, **kwargs)

source code 

this function defines: self.connection and self.cursor (iff cursor is True) if self.pool_size>0 it will try pull the connection from the pool if the connection is not active (closed by db server) it will loop if not self.pool_size or no active connections in pool makes a new one

Overrides: ConnectionPool.reconnect
(inherited documentation)

file_exists(self, filename)

source code 

to be used ONLY for files that on GAE may not be on filesystem

Overrides: BaseAdapter.file_exists
(inherited documentation)

file_open(self, filename, mode='rb', lock=True)

source code 

to be used ONLY for files that on GAE may not be on filesystem

Overrides: BaseAdapter.file_open
(inherited documentation)

file_close(self, fileobj)

source code 

to be used ONLY for files that on GAE may not be on filesystem

Overrides: BaseAdapter.file_close
(inherited documentation)

__init__(self, db, uri, pool_size=0, folder=None, db_codec='UTF-8', credential_decoder=<function IDENTITY at 0x334cd70>, driver_args={}, adapter_args={}, do_connect=True, after_connection=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

parse_id(self, value, field_type)

source code 
Overrides: BaseAdapter.parse_id

create_table(self, table, migrate=True, fake_migrate=False, polymodel=None)

source code 
Overrides: BaseAdapter.create_table

expand(self, expression, field_type=None)

source code 
Overrides: BaseAdapter.expand

AND(self, first, second)

source code 
Overrides: BaseAdapter.AND

EQ(self, first, second=None)

source code 
Overrides: BaseAdapter.EQ

NE(self, first, second=None)

source code 
Overrides: BaseAdapter.NE

LT(self, first, second=None)

source code 
Overrides: BaseAdapter.LT

LE(self, first, second=None)

source code 
Overrides: BaseAdapter.LE

GT(self, first, second=None)

source code 
Overrides: BaseAdapter.GT

GE(self, first, second=None)

source code 
Overrides: BaseAdapter.GE

INVERT(self, first)

source code 
Overrides: BaseAdapter.INVERT

COMMA(self, first, second)

source code 
Overrides: BaseAdapter.COMMA

BELONGS(self, first, second=None)

source code 
Overrides: BaseAdapter.BELONGS

CONTAINS(self, first, second, case_sensitive=False)

source code 
Overrides: BaseAdapter.CONTAINS

NOT(self, first)

source code 
Overrides: BaseAdapter.NOT

truncate(self, table, mode)

source code 
Overrides: BaseAdapter.truncate

select(self, query, fields, attributes)

source code 

This is the GAE version of select. some notes to consider:

  • db['_lastsql'] is not set because there is not SQL statement string for a GAE query
  • 'nativeRef' is a magical fieldname used for self references on GAE
  • optional attribute 'projection' when set to True will trigger use of the GAE projection queries. note that there are rules for what is accepted imposed by GAE: each field must be indexed, projection queries cannot contain blob or text fields, and you cannot use == and also select that same field. see https://developers.google.com/appengine/docs/python/datastore/queries#Query_Projection
  • optional attribute 'filterfields' when set to True web2py will only parse the explicitly listed fields into the Rows object, even though all fields are returned in the query. This can be used to reduce memory usage in cases where true projection queries are not usable.
  • optional attribute 'reusecursor' allows use of cursor with queries that have the limitby attribute. Set the attribute to True for the first query, set it to the value of db['_lastcursor'] to continue a previous query. The user must save the cursor value between requests, and the filters must be identical. It is up to the user to follow google's limitations: https://developers.google.com/appengine/docs/python/datastore/queries#Query_Cursors
Overrides: BaseAdapter.select

parse_list_integers(self, value, field_type)

source code 
Overrides: BaseAdapter.parse_list_integers

parse_list_strings(self, value, field_type)

source code 
Overrides: BaseAdapter.parse_list_strings

count(self, query, distinct=None, limit=None)

source code 
Overrides: BaseAdapter.count

delete(self, tablename, query)

source code 

This function was changed on 2010-05-04 because according to http://code.google.com/p/googleappengine/issues/detail?id=3119 GAE no longer supports deleting more than 1000 records.

Overrides: BaseAdapter.delete

update(self, tablename, query, update_fields)

source code 
Overrides: BaseAdapter.update

insert(self, table, fields)

source code 
Overrides: BaseAdapter.insert

bulk_insert(self, table, items)

source code 
Overrides: BaseAdapter.bulk_insert

Class Variable Details [hide private]

GAE_FILTER_OPTIONS

Value:
{'=': lambda q, t, p, v: q.filter(getattr(t, p)== v), '>': lambda q, t\
, p, v: q.filter(getattr(t, p) > v), '<': lambda q, t, p, v: q.filter(\
getattr(t, p) < v), '<=': lambda q, t, p, v: q.filter(getattr(t, p) <=\
 v), '>=': lambda q, t, p, v: q.filter(getattr(t, p) >= v), '!=': lamb\
da q, t, p, v: q.filter(getattr(t, p) != v), 'in': lambda q, t, p, v: \
q.filter(getattr(t, p).IN(v)),}