當前位置: 首頁>>代碼示例>>Python>>正文


Python TableService.get_entity方法代碼示例

本文整理匯總了Python中azure.storage.TableService.get_entity方法的典型用法代碼示例。如果您正苦於以下問題:Python TableService.get_entity方法的具體用法?Python TableService.get_entity怎麽用?Python TableService.get_entity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在azure.storage.TableService的用法示例。


在下文中一共展示了TableService.get_entity方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: friend_email_add

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
def friend_email_add(mine,friend):
    #SEE if my tuple is there .. is not then create and add else simple merge
    print("\n\n\n\n\ running addin table ")
    table_service = TableService(account_name='*****', account_key='******')
    try:
        task = table_service.get_entity('friendlisttable', 'friend', mine)
        count=task.count
        print(count)
        field="friend"+str(count+1)
        data={field:friend,'count':(count+1)}
        table_service.insert_or_merge_entity('friendlisttable','friend',mine,data)
        print("value 1 inserted via merge")
    except Exception as e:
        print(e)
        print("your account was not there")
        data= {'PartitionKey':'friend','RowKey':mine,'count':1,'friend1':friend}
        table_service.insert_entity('friendlisttable', data)
        print("value 1 added via create")
    try:
        task = table_service.get_entity('friendlisttable', 'friend', friend)
        count=task.count
        print(count)
        field="friend"+str(count+1)
        data={field:mine,'count':(count+1)}
        table_service.insert_or_merge_entity('friendlisttable','friend',friend,data)
        print("value 2 inserted via merge")
    except Exception as e:
        print(e)
        print("your account was not there")
        data= {'PartitionKey':'friend','RowKey':friend,'count':1,'friend1':mine}
        table_service.insert_entity('friendlisttable', data)
        print("value 2 added via create")
    print("added al \n\n\n ")
開發者ID:HIMANSHURANJAN2015,項目名稱:clique,代碼行數:35,代碼來源:views.py

示例2: friend_email_get

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
def friend_email_get(mine):
    l=[]
    try:
        # will return a list of email ids of freinds
        table_service = TableService(account_name='****', account_key='******')
        #since table is already created
        #table_service.create_table('friendstable')
        tuple1 = table_service.get_entity('friendlisttable', 'friend', mine)
        count=tuple1.count
        for i in range(1,count+1):
            field="friend"+str(i);
            k_dict=tuple1.__dict__
            print("\n\n",k_dict,"\n\n") 
            data=k_dict[field]
            print("\n\n",data)
            l.append(data)
        print("\n\n",l,"\n\n")
    except Exception as e:
        print(e)
    return l
開發者ID:HIMANSHURANJAN2015,項目名稱:clique,代碼行數:22,代碼來源:views.py

示例3: str

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
    image = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
    # put to blob smaller version
    lol ,image_tn = cv2.imencode( '.jpg', image )
    blob_service.put_block_blob_from_bytes( blob_container, imgBlobName, str(bytearray(image_tn.flatten().tolist())) )
    ############################################################################


    # process image
    colourStructure = getCharacteristics( image, region, results )

    blob_service.put_block_blob_from_bytes( blob_analysis, imgBlobName, dumps(colourStructure) )

    # {'PartitionKey': 'allPhotos', 'RowKey': 'imageName', 'thumbnail' : 'thumbnailName',
    #  'userId' : ?, 'local' : ?, 'hue' : 200, 'saturation' : 200, 'value' : 200}
    ## query for image in table to ensure existence
    currentTask = table_service.get_entity( tableName, tablePartitionKey, tableRowKey)

    
  
    ## send the quantities to table: save thumbnail ID & save image characteristics
    # currentTask.thumbnail = tnID
    currentTask.analysed = True
    table_service.update_entity( tableName, tablePartitionKey, tableRowKey, currentTask)

    # dequeue image
    queue_service.delete_message( imagesQueue, message.message_id, message.pop_receipt )



# Get the mosaic image from some queue
開發者ID:macqm,項目名稱:mosaic-opencv,代碼行數:32,代碼來源:analyse.cv.py

示例4: TableServiceTest

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]

#.........這裏部分代碼省略.........
        # Arrange
        self._create_table(self.table_name)

        # Act
        dict = self._create_default_entity_dict('MyPartition', '1')
        resp = self.ts.insert_entity(self.table_name, dict)

        # Assert
        self.assertIsNotNone(resp)

    def test_insert_entity_class_instance(self):
        # Arrange
        self._create_table(self.table_name)

        # Act
        entity = self._create_default_entity_class('MyPartition', '1')
        resp = self.ts.insert_entity(self.table_name, entity)

        # Assert
        self.assertIsNotNone(resp)

    def test_insert_entity_conflict(self):
        # Arrange
        self._create_table_with_default_entities(self.table_name, 1)

        # Act
        with self.assertRaises(WindowsAzureError):
            self.ts.insert_entity(
                self.table_name,
                self._create_default_entity_dict('MyPartition', '1'))

        # Assert

    def test_get_entity(self):
        # Arrange
        self._create_table_with_default_entities(self.table_name, 1)

        # Act
        resp = self.ts.get_entity(self.table_name, 'MyPartition', '1')

        # Assert
        self.assertEqual(resp.PartitionKey, 'MyPartition')
        self.assertEqual(resp.RowKey, '1')
        self._assert_default_entity(resp)

    def test_get_entity_not_existing(self):
        # Arrange
        self._create_table(self.table_name)

        # Act
        with self.assertRaises(WindowsAzureError):
            self.ts.get_entity(self.table_name, 'MyPartition', '1')

        # Assert

    def test_get_entity_with_select(self):
        # Arrange
        self._create_table_with_default_entities(self.table_name, 1)

        # Act
        resp = self.ts.get_entity(
            self.table_name, 'MyPartition', '1', 'age,sex')

        # Assert
        self.assertEqual(resp.age, 39)
        self.assertEqual(resp.sex, 'male')
開發者ID:algaruda,項目名稱:azure-sdk-for-python,代碼行數:70,代碼來源:test_tableservice.py

示例5: TableService

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
#update test cat's owner
#whom we will send messages
from azure.storage import TableService
import config
table_service = TableService(account_name=config.ACC_NAME, 
                             account_key=config.ACC_KEY)
#newMaster = {'masterID' : '188622142'}
#table_service.update_entity('bandcredentials', 'band','test', newMaster)
#table_service.insert_entity('bandcredentials', newMaster)

task = table_service.get_entity('bandcredentials', 'band', 'test')
print task.masterID
開發者ID:catInet,項目名稱:landingPage,代碼行數:14,代碼來源:setTestMasterForCat.py

示例6: TableService

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
#coding:utf8

from azure.storage import TableService, Entity

table_service = TableService(account_name='portalvhdspbrd34f2fnbl', 
account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')

task = table_service.get_entity('tasktable', 'tasksSeattle', '1')
print(task.description)
print(task.priority)
開發者ID:freshmenyuan,項目名稱:PointOfSale,代碼行數:12,代碼來源:readtest.py

示例7: TableService

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
from azure.storage import TableService, Entity

table_service = TableService(account_name='myaccount', account_key='myKey')

task = table_service.get_entity('tasktable', 'toDoTasks', '1')
print(task.description)
print(task.priority)

task = table_service.get_entity('tasktable', 'toDoTasks', '4')
print(task.description)
print(task.priority)




開發者ID:sasmishi,項目名稱:mySamples,代碼行數:13,代碼來源:query.py

示例8: TableServiceTest

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]

#.........這裏部分代碼省略.........
    #--Test cases for entities ------------------------------------------
    def test_insert_entity_dictionary(self):
        # Arrange
        self._create_table(self.table_name)

        # Act
        dict = self._create_default_entity_dict('MyPartition', '1')
        resp = self.tc.insert_entity(self.table_name, dict)

        # Assert
        self.assertIsNotNone(resp)

    def test_insert_entity_class_instance(self):
        # Arrange
        self._create_table(self.table_name)

        # Act
        entity = self._create_default_entity_class('MyPartition', '1')
        resp = self.tc.insert_entity(self.table_name, entity)

        # Assert
        self.assertIsNotNone(resp)

    def test_insert_entity_conflict(self):
        # Arrange
        self._create_table_with_default_entities(self.table_name, 1)

        # Act
        with self.assertRaises(WindowsAzureError):
            self.tc.insert_entity(self.table_name, self._create_default_entity_dict('MyPartition', '1'))

        # Assert

    def test_get_entity(self):
        # Arrange
        self._create_table_with_default_entities(self.table_name, 1)

        # Act
        resp = self.tc.get_entity(self.table_name, 'MyPartition', '1')

        # Assert
        self.assertEquals(resp.PartitionKey, 'MyPartition')
        self.assertEquals(resp.RowKey, '1')
        self._assert_default_entity(resp)

    def test_get_entity_not_existing(self):
        # Arrange
        self._create_table(self.table_name)

        # Act
        with self.assertRaises(WindowsAzureError):
            self.tc.get_entity(self.table_name, 'MyPartition', '1')

        # Assert

    def test_get_entity_with_select(self):
        # Arrange
        self._create_table_with_default_entities(self.table_name, 1)

        # Act
        resp = self.tc.get_entity(self.table_name, 'MyPartition', '1', 'age,sex')

        # Assert
        self.assertEquals(resp.age, 39)
        self.assertEquals(resp.sex, 'male')
        self.assertFalse(hasattr(resp, "birthday"))
開發者ID:Bunkerbewohner,項目名稱:azure-sdk-for-python,代碼行數:70,代碼來源:test_tableservice.py

示例9: TableService

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
#!/usr/bin/env python

from azure.storage import TableService
from datetime import datetime

ts = TableService(account_name='freedu', account_key='P0WNSyFp2Fs32lTY52bN3DFFq/wPQcaBGbnC7xMOcS4U2zsXJoASgVUqux0TEtVgqn8Wfl6jxXpkGfy5ZaWCzQ==')

try:
    ts.create_table('tasktable')
    ts.insert_entity(
         'tasktable',
         {
            'PartitionKey' : 'tasksSeattle',
            'RowKey': '1',
            'Description': 'Take out the trash',
            'DueDate': datetime(2011, 12, 14, 12) 
        }
    )
except Exception,ex:
    print ex

print 'create table done.'

entity = ts.get_entity('tasktable', 'tasksSeattle', '1')
print 'get_entity done.'
print entity
開發者ID:jiayuhu,項目名稱:freedu,代碼行數:28,代碼來源:initdb.py

示例10: Repository

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
class Repository(object):
    """Azure Table Storage repository."""
    def __init__(self, settings):
        """Initializes the repository with the specified settings dict.
        Required settings are:
         - STORAGE_NAME
         - STORAGE_KEY
         - STORAGE_TABLE_POLL
         - STORAGE_TABLE_CHOICE
        """
        self.name = 'Azure Table Storage'
        self.storage_name = settings['STORAGE_NAME']
        self.storage_key = settings['STORAGE_KEY']
        self.poll_table = settings['STORAGE_TABLE_POLL']
        self.choice_table = settings['STORAGE_TABLE_CHOICE']

        self.svc = TableService(self.storage_name, self.storage_key)
        self.svc.create_table(self.poll_table)
        self.svc.create_table(self.choice_table)

    def get_polls(self):
        """Returns all the polls from the repository."""
        poll_entities = self.svc.query_entities(self.poll_table)
        polls = [_poll_from_entity(entity) for entity in poll_entities]
        return polls

    def get_poll(self, poll_key):
        """Returns a poll from the repository."""
        try:
            partition, row = _key_to_partition_and_row(poll_key)
            poll_entity = self.svc.get_entity(self.poll_table, partition, row)
            choice_entities = self.svc.query_entities(
                self.choice_table,
                "PollPartitionKey eq '{0}' and PollRowKey eq '{1}'" \
                    .format(partition, row)
            )

            poll = _poll_from_entity(poll_entity)
            poll.choices = [_choice_from_entity(choice_entity)
                            for choice_entity in choice_entities]
            return poll
        except WindowsAzureMissingResourceError:
            raise PollNotFound()

    def increment_vote(self, poll_key, choice_key):
        """Increment the choice vote count for the specified poll."""
        try:
            partition, row = _key_to_partition_and_row(choice_key)
            entity = self.svc.get_entity(self.choice_table, partition, row)
            entity.Votes += 1
            self.svc.update_entity(self.choice_table, partition, row, entity)
        except WindowsAzureMissingResourceError:
            raise PollNotFound()

    def add_sample_polls(self):
        """Adds a set of polls from data stored in a samples.json file."""
        poll_partition = '2014'
        poll_row = 0
        choice_partition = '2014'
        choice_row = 0

        for sample_poll in _load_samples_json():
            poll_entity = {
                'PartitionKey': poll_partition,
                'RowKey': str(poll_row),
                'Text': sample_poll['text'],
            }
            self.svc.insert_entity(self.poll_table, poll_entity)

            for sample_choice in sample_poll['choices']:
                choice_entity = {
                    'PartitionKey': choice_partition,
                    'RowKey': str(choice_row),
                    'Text': sample_choice,
                    'Votes': 0,
                    'PollPartitionKey': poll_partition,
                    'PollRowKey': str(poll_row),
                }
                self.svc.insert_entity(self.choice_table, choice_entity)
                choice_row += 1

            poll_row += 1
開發者ID:CloudeXpert,項目名稱:PTVS,代碼行數:84,代碼來源:azuretablestorage.py

示例11: AzureGaugeDatastore

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
class AzureGaugeDatastore(GaugeDatastore):
    """Stores gauge data in Azure Table storage. Utilizes table storage
    as follows:

    PartitionKey: gauge name
    RowKey: date key (e.g. day string)
    data: stored data for date key
    Timestamp: last time data updated

    Replaces existing rows (PK+RK) with upsert queries. Has a limitation of
    returning max 1000 rows in a query. This suffices for now.
    """

    table_service = None
    table_name = None

    def __init__(self, account_name, account_key, table_name):
        self.table_name = table_name
        self.table_service = TableService(account_name, account_key)

    def save_data(self, gauge_name, date_key, data):
        """Saves data to the table row of date_key (replaces if exists)
        """

        entity = {'PartitionKey': gauge_name, 'RowKey': date_key, 'data': data}
        self.table_service.insert_or_replace_entity(self.table_name,
                                                    gauge_name, date_key,
                                                    entity)

    def get_gauge_data(self, gauge_name, min_date_key=None, max_date_key=None):
        """Retrieves all gauge data, returns unsorted.

        If min_date_key is specified, returns records with
        date_key >= min_date_key

        If max_date_key is specified, returns records with
        date_key < max_date_key

        IMPORTANT NOTE: Azure Table REST API returns first (oldest) 1000 rows
        in API call. Unless we add RowKey>min_date_key filter, after 1000
        rows (e.g. after 1000 days of recording) no fresh results will be
        returned.
        """

        query = "PartitionKey eq '{0}'".format(gauge_name)

        if min_date_key:
            query = "{0} and RowKey ge '{1}'".format(query, min_date_key)

        if max_date_key:
            query = "{0} and RowKey lt '{1}'".format(query, max_date_key)

        rows = self.table_service.query_entities(self.table_name, filter=query)
        if rows:
            return [make_record(record.RowKey, record.data) for record in rows]

    def get_data(self, gauge_name, date_key):
        """Retrieves gauge data for a specific date key (e.g. day)
        """

        rec = self.table_service.get_entity(self.table_name, gauge_name,
                                            date_key)
        if not rec:
            return None
        return helpers.make_record(rec.RowKey, rec.data)
開發者ID:ahmetalpbalkan,項目名稱:simplegauges,代碼行數:67,代碼來源:azuretable.py

示例12: TableService

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import get_entity [as 別名]
from azure.storage import TableService, Entity

table_service = TableService(account_name='upmsample', account_key='5YC/6x9KL56rtaAUAZMgGsREDvvPHYJIMqH3z1c9IgQLy0qMP+Awr+7j51Tfzniczj//6jn7lvYQutD/mHm6dw==')

table_service.create_table('ledtracktable')

task = table_service.get_entity('ledtracktable', 'ledswitch', '1')
print(task.state)


開發者ID:sasmita,項目名稱:myExperiments,代碼行數:10,代碼來源:ledgetState.py


注:本文中的azure.storage.TableService.get_entity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。