db/python/tables/sample.py
async def insert_sample(
        self,
        external_id,
        sample_type: SampleType,
        active,
        meta=None,
        participant_id=None,
        author=None,
        project=None,
    ) -> int:
        """
        Create a new sample, and add it to database
        """

        kv_pairs = [
            ('external_id', external_id),
            ('participant_id', participant_id),
            ('meta', to_db_json(meta)),
            ('type', sample_type.value),
            ('active', active),
            ('author', author or self.author),
            ('project', project or self.project),
        ]

        keys = [k for k, _ in kv_pairs]
        cs_keys = ', '.join(keys)
        cs_id_keys = ', '.join(f':{k}' for k in keys)
        _query = f"""\
INSERT INTO sample
    ({cs_keys})
VALUES ({cs_id_keys}) RETURNING id;"""

        id_of_new_sample = await self.connection.fetch_val(
            _query,
            dict(kv_pairs),
        )

        return id_of_new_sample

        Create a new sample, and add it to database
        
Create a new sample, and add it to database
Create a new sample and add it to database
async def insert_sample(
        self,
        external_id,
        sample_type: SampleType,
        active,
        meta=None,
        participant_id=None,
        author=None,
        project=None,
    ) -> int:
        kv_pairs = [
            ('external_id', external_id),
            ('participant_id', participant_id),
            ('meta', to_db_json(meta)),
            ('type', sample_type.value),
            ('active', active),
            ('author', author or self.author),
            ('project', project or self.project),
        ]
        keys = [k for k, _ in kv_pairs]
        cs_keys = ', '.join(keys)
        cs_id_keys = ', '.join(f':{k}' for k in keys)
        _query = f"""\
INSERT INTO sample
    ({cs_keys})
VALUES ({cs_id_keys}) RETURNING id;"""
        id_of_new_sample = await self.connection.fetch_val(
            _query,
            dict(kv_pairs),
        )
        return id_of_new_sample
async def insert_sample ( self , external_id , sample_type : SampleType , active , meta = None , participant_id = None , author = None , project = None , ) -> int : kv_pairs = [ ( 'external_id' , external_id ) , ( 'participant_id' , participant_id ) , ( 'meta' , to_db_json ( meta ) ) , ( 'type' , sample_type . value ) , ( 'active' , active ) , ( 'author' , author or self . author ) , ( 'project' , project or self . project ) , ] keys = [ k for k , _ in kv_pairs ] cs_keys = ', ' . join ( keys ) cs_id_keys = ', ' . join ( f':{k}' for k in keys ) _query = f"""\
INSERT INTO sample
    ({cs_keys})
VALUES ({cs_id_keys}) RETURNING id;""" id_of_new_sample = await self . connection . fetch_val ( _query , dict ( kv_pairs ) , ) return id_of_new_sample
Create a new sample, and add it to database
Create a new sample and add it to database
"""
        Create a new sample, and add it to database
        """
self
external_id
sample_type
SampleType
active
meta
participant_id
author
project