pylav.storage.database.tables package

Submodules

pylav.storage.database.tables.aiohttp_cache module

class pylav.storage.database.tables.aiohttp_cache.AioHttpCacheRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

key

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
value

Used for storing bytes.

Example

class Token(Table):
    token = Bytea(default=b'token123')

# Create
>>> await Token(token=b'my-token').save()

# Query
>>> await Token.select(Token.token)
{'token': b'my-token'}

pylav.storage.database.tables.config module

class pylav.storage.database.tables.config.LibConfigRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

auto_update_managed_nodes

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
bot

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
config_folder

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
download_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
enable_managed_node

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
extras

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
java_path

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
localtrack_folder

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
next_execution_update_bundled_external_playlists

Used for storing timezone aware datetimes. Uses the datetime type for values. The values are converted to UTC in the database, and are also returned as UTC.

Example

import datetime

class Concert(Table):
    starts = Timestamptz()

# Create
>>> await Concert(
...    starts=datetime.datetime(
...        year=2050, month=1, day=1, tzinfo=datetime.timezone.tz
...    )
... ).save()

# Query
>>> await Concert.select(Concert.starts)
{
    'starts': datetime.datetime(
        2050, 1, 1, 0, 0, tzinfo=datetime.timezone.utc
    )
}
next_execution_update_bundled_playlists

Used for storing timezone aware datetimes. Uses the datetime type for values. The values are converted to UTC in the database, and are also returned as UTC.

Example

import datetime

class Concert(Table):
    starts = Timestamptz()

# Create
>>> await Concert(
...    starts=datetime.datetime(
...        year=2050, month=1, day=1, tzinfo=datetime.timezone.tz
...    )
... ).save()

# Query
>>> await Concert.select(Concert.starts)
{
    'starts': datetime.datetime(
        2050, 1, 1, 0, 0, tzinfo=datetime.timezone.utc
    )
}
next_execution_update_external_playlists

Used for storing timezone aware datetimes. Uses the datetime type for values. The values are converted to UTC in the database, and are also returned as UTC.

Example

import datetime

class Concert(Table):
    starts = Timestamptz()

# Create
>>> await Concert(
...    starts=datetime.datetime(
...        year=2050, month=1, day=1, tzinfo=datetime.timezone.tz
...    )
... ).save()

# Query
>>> await Concert.select(Concert.starts)
{
    'starts': datetime.datetime(
        2050, 1, 1, 0, 0, tzinfo=datetime.timezone.utc
    )
}
update_bot_activity

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
use_bundled_pylav_external

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}

pylav.storage.database.tables.equalizer module

class pylav.storage.database.tables.equalizer.EqualizerRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

author

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
band_100

An alias for Real.

band_1000

An alias for Real.

band_10000

An alias for Real.

band_160

An alias for Real.

band_1600

An alias for Real.

band_16000

An alias for Real.

band_25

An alias for Real.

band_250

An alias for Real.

band_2500

An alias for Real.

band_40

An alias for Real.

band_400

An alias for Real.

band_4000

An alias for Real.

band_63

An alias for Real.

band_630

An alias for Real.

band_6300

An alias for Real.

description

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
name

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
scope

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}

pylav.storage.database.tables.m2m module

class pylav.storage.database.tables.m2m.TrackToPlaylists(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

id

An alias to an autoincrementing integer column in Postgres.

playlists

Used to reference another table. Uses the same type as the primary key column on the table it references.

Example

class Band(Table):
    manager = ForeignKey(references=Manager)

# Create
>>> await Band(manager=1).save()

# Query
>>> await Band.select(Band.manager)
{'manager': 1}

# Query object
>>> band = await Band.objects().first()
>>> band.manager
1

Joins

You also use it to perform joins:

>>> await Band.select(Band.name, Band.manager.name).first()
{'name': 'Pythonistas', 'manager.name': 'Guido'}

To retrieve all of the columns in the related table:

>>> await Band.select(Band.name, *Band.manager.all_columns()).first()
{'name': 'Pythonistas', 'manager.id': 1, 'manager.name': 'Guido'}

To get a referenced row as an object:

manager = await Manager.objects().where(
    Manager.id == some_band.manager
)

Or use either of the following, which are just a proxy to the above:

manager = await band.get_related('manager')
manager = await band.get_related(Band.manager)

To change the manager:

band.manager = some_manager_id
await band.save()
Parameters:
  • references

    The Table being referenced.

    class Band(Table):
        manager = ForeignKey(references=Manager)
    

    A table can have a reference to itself, if you pass a references argument of 'self'.

    class Musician(Table):
        name = Varchar(length=100)
        instructor = ForeignKey(references='self')
    

    In certain situations, you may be unable to reference a Table class if it causes a circular dependency. Try and avoid these by refactoring your code. If unavoidable, you can specify a lazy reference. If the Table is defined in the same file:

    class Band(Table):
        manager = ForeignKey(references='Manager')
    

    If the Table is defined in a Piccolo app:

    from piccolo.columns.reference import LazyTableReference
    
    class Band(Table):
        manager = ForeignKey(
            references=LazyTableReference(
               table_class_name="Manager", app_name="my_app",
            )
        )
    

    If you aren’t using Piccolo apps, you can specify a Table in any Python module:

    from piccolo.columns.reference import LazyTableReference
    
    class Band(Table):
        manager = ForeignKey(
            references=LazyTableReference(
               table_class_name="Manager",
               module_path="some_module.tables",
            )
            # Alternatively, Piccolo will interpret this string as
            # the same as above:
            # references="some_module.tables.Manager"
        )
    

  • on_delete

    Determines what the database should do when a row is deleted with foreign keys referencing it. If set to OnDelete.cascade, any rows referencing the deleted row are also deleted.

    Options:

    • OnDelete.cascade (default)

    • OnDelete.restrict

    • OnDelete.no_action

    • OnDelete.set_null

    • OnDelete.set_default

    To learn more about the different options, see the Postgres docs.

    from piccolo.columns import OnDelete
    
    class Band(Table):
        name = ForeignKey(
            references=Manager,
            on_delete=OnDelete.cascade
        )
    

  • on_update

    Determines what the database should do when a row has it’s primary key updated. If set to OnUpdate.cascade, any rows referencing the updated row will have their references updated to point to the new primary key.

    Options:

    • OnUpdate.cascade (default)

    • OnUpdate.restrict

    • OnUpdate.no_action

    • OnUpdate.set_null

    • OnUpdate.set_default

    To learn more about the different options, see the Postgres docs.

    from piccolo.columns import OnUpdate
    
    class Band(Table):
        name = ForeignKey(
            references=Manager,
            on_update=OnUpdate.cascade
        )
    

  • target_column

    By default the ForeignKey references the primary key column on the related table. You can specify an alternative column (it must have a unique constraint on it though). For example:

    # Passing in a column reference:
    ForeignKey(references=Manager, target_column=Manager.passport_number)
    
    # Or just the column name:
    ForeignKey(references=Manager, target_column='passport_number')
    

tracks

Used to reference another table. Uses the same type as the primary key column on the table it references.

Example

class Band(Table):
    manager = ForeignKey(references=Manager)

# Create
>>> await Band(manager=1).save()

# Query
>>> await Band.select(Band.manager)
{'manager': 1}

# Query object
>>> band = await Band.objects().first()
>>> band.manager
1

Joins

You also use it to perform joins:

>>> await Band.select(Band.name, Band.manager.name).first()
{'name': 'Pythonistas', 'manager.name': 'Guido'}

To retrieve all of the columns in the related table:

>>> await Band.select(Band.name, *Band.manager.all_columns()).first()
{'name': 'Pythonistas', 'manager.id': 1, 'manager.name': 'Guido'}

To get a referenced row as an object:

manager = await Manager.objects().where(
    Manager.id == some_band.manager
)

Or use either of the following, which are just a proxy to the above:

manager = await band.get_related('manager')
manager = await band.get_related(Band.manager)

To change the manager:

band.manager = some_manager_id
await band.save()
Parameters:
  • references

    The Table being referenced.

    class Band(Table):
        manager = ForeignKey(references=Manager)
    

    A table can have a reference to itself, if you pass a references argument of 'self'.

    class Musician(Table):
        name = Varchar(length=100)
        instructor = ForeignKey(references='self')
    

    In certain situations, you may be unable to reference a Table class if it causes a circular dependency. Try and avoid these by refactoring your code. If unavoidable, you can specify a lazy reference. If the Table is defined in the same file:

    class Band(Table):
        manager = ForeignKey(references='Manager')
    

    If the Table is defined in a Piccolo app:

    from piccolo.columns.reference import LazyTableReference
    
    class Band(Table):
        manager = ForeignKey(
            references=LazyTableReference(
               table_class_name="Manager", app_name="my_app",
            )
        )
    

    If you aren’t using Piccolo apps, you can specify a Table in any Python module:

    from piccolo.columns.reference import LazyTableReference
    
    class Band(Table):
        manager = ForeignKey(
            references=LazyTableReference(
               table_class_name="Manager",
               module_path="some_module.tables",
            )
            # Alternatively, Piccolo will interpret this string as
            # the same as above:
            # references="some_module.tables.Manager"
        )
    

  • on_delete

    Determines what the database should do when a row is deleted with foreign keys referencing it. If set to OnDelete.cascade, any rows referencing the deleted row are also deleted.

    Options:

    • OnDelete.cascade (default)

    • OnDelete.restrict

    • OnDelete.no_action

    • OnDelete.set_null

    • OnDelete.set_default

    To learn more about the different options, see the Postgres docs.

    from piccolo.columns import OnDelete
    
    class Band(Table):
        name = ForeignKey(
            references=Manager,
            on_delete=OnDelete.cascade
        )
    

  • on_update

    Determines what the database should do when a row has it’s primary key updated. If set to OnUpdate.cascade, any rows referencing the updated row will have their references updated to point to the new primary key.

    Options:

    • OnUpdate.cascade (default)

    • OnUpdate.restrict

    • OnUpdate.no_action

    • OnUpdate.set_null

    • OnUpdate.set_default

    To learn more about the different options, see the Postgres docs.

    from piccolo.columns import OnUpdate
    
    class Band(Table):
        name = ForeignKey(
            references=Manager,
            on_update=OnUpdate.cascade
        )
    

  • target_column

    By default the ForeignKey references the primary key column on the related table. You can specify an alternative column (it must have a unique constraint on it though). For example:

    # Passing in a column reference:
    ForeignKey(references=Manager, target_column=Manager.passport_number)
    
    # Or just the column name:
    ForeignKey(references=Manager, target_column='passport_number')
    

class pylav.storage.database.tables.m2m.TrackToQueries(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

id

An alias to an autoincrementing integer column in Postgres.

queries

Used to reference another table. Uses the same type as the primary key column on the table it references.

Example

class Band(Table):
    manager = ForeignKey(references=Manager)

# Create
>>> await Band(manager=1).save()

# Query
>>> await Band.select(Band.manager)
{'manager': 1}

# Query object
>>> band = await Band.objects().first()
>>> band.manager
1

Joins

You also use it to perform joins:

>>> await Band.select(Band.name, Band.manager.name).first()
{'name': 'Pythonistas', 'manager.name': 'Guido'}

To retrieve all of the columns in the related table:

>>> await Band.select(Band.name, *Band.manager.all_columns()).first()
{'name': 'Pythonistas', 'manager.id': 1, 'manager.name': 'Guido'}

To get a referenced row as an object:

manager = await Manager.objects().where(
    Manager.id == some_band.manager
)

Or use either of the following, which are just a proxy to the above:

manager = await band.get_related('manager')
manager = await band.get_related(Band.manager)

To change the manager:

band.manager = some_manager_id
await band.save()
Parameters:
  • references

    The Table being referenced.

    class Band(Table):
        manager = ForeignKey(references=Manager)
    

    A table can have a reference to itself, if you pass a references argument of 'self'.

    class Musician(Table):
        name = Varchar(length=100)
        instructor = ForeignKey(references='self')
    

    In certain situations, you may be unable to reference a Table class if it causes a circular dependency. Try and avoid these by refactoring your code. If unavoidable, you can specify a lazy reference. If the Table is defined in the same file:

    class Band(Table):
        manager = ForeignKey(references='Manager')
    

    If the Table is defined in a Piccolo app:

    from piccolo.columns.reference import LazyTableReference
    
    class Band(Table):
        manager = ForeignKey(
            references=LazyTableReference(
               table_class_name="Manager", app_name="my_app",
            )
        )
    

    If you aren’t using Piccolo apps, you can specify a Table in any Python module:

    from piccolo.columns.reference import LazyTableReference
    
    class Band(Table):
        manager = ForeignKey(
            references=LazyTableReference(
               table_class_name="Manager",
               module_path="some_module.tables",
            )
            # Alternatively, Piccolo will interpret this string as
            # the same as above:
            # references="some_module.tables.Manager"
        )
    

  • on_delete

    Determines what the database should do when a row is deleted with foreign keys referencing it. If set to OnDelete.cascade, any rows referencing the deleted row are also deleted.

    Options:

    • OnDelete.cascade (default)

    • OnDelete.restrict

    • OnDelete.no_action

    • OnDelete.set_null

    • OnDelete.set_default

    To learn more about the different options, see the Postgres docs.

    from piccolo.columns import OnDelete
    
    class Band(Table):
        name = ForeignKey(
            references=Manager,
            on_delete=OnDelete.cascade
        )
    

  • on_update

    Determines what the database should do when a row has it’s primary key updated. If set to OnUpdate.cascade, any rows referencing the updated row will have their references updated to point to the new primary key.

    Options:

    • OnUpdate.cascade (default)

    • OnUpdate.restrict

    • OnUpdate.no_action

    • OnUpdate.set_null

    • OnUpdate.set_default

    To learn more about the different options, see the Postgres docs.

    from piccolo.columns import OnUpdate
    
    class Band(Table):
        name = ForeignKey(
            references=Manager,
            on_update=OnUpdate.cascade
        )
    

  • target_column

    By default the ForeignKey references the primary key column on the related table. You can specify an alternative column (it must have a unique constraint on it though). For example:

    # Passing in a column reference:
    ForeignKey(references=Manager, target_column=Manager.passport_number)
    
    # Or just the column name:
    ForeignKey(references=Manager, target_column='passport_number')
    

tracks

Used to reference another table. Uses the same type as the primary key column on the table it references.

Example

class Band(Table):
    manager = ForeignKey(references=Manager)

# Create
>>> await Band(manager=1).save()

# Query
>>> await Band.select(Band.manager)
{'manager': 1}

# Query object
>>> band = await Band.objects().first()
>>> band.manager
1

Joins

You also use it to perform joins:

>>> await Band.select(Band.name, Band.manager.name).first()
{'name': 'Pythonistas', 'manager.name': 'Guido'}

To retrieve all of the columns in the related table:

>>> await Band.select(Band.name, *Band.manager.all_columns()).first()
{'name': 'Pythonistas', 'manager.id': 1, 'manager.name': 'Guido'}

To get a referenced row as an object:

manager = await Manager.objects().where(
    Manager.id == some_band.manager
)

Or use either of the following, which are just a proxy to the above:

manager = await band.get_related('manager')
manager = await band.get_related(Band.manager)

To change the manager:

band.manager = some_manager_id
await band.save()
Parameters:
  • references

    The Table being referenced.

    class Band(Table):
        manager = ForeignKey(references=Manager)
    

    A table can have a reference to itself, if you pass a references argument of 'self'.

    class Musician(Table):
        name = Varchar(length=100)
        instructor = ForeignKey(references='self')
    

    In certain situations, you may be unable to reference a Table class if it causes a circular dependency. Try and avoid these by refactoring your code. If unavoidable, you can specify a lazy reference. If the Table is defined in the same file:

    class Band(Table):
        manager = ForeignKey(references='Manager')
    

    If the Table is defined in a Piccolo app:

    from piccolo.columns.reference import LazyTableReference
    
    class Band(Table):
        manager = ForeignKey(
            references=LazyTableReference(
               table_class_name="Manager", app_name="my_app",
            )
        )
    

    If you aren’t using Piccolo apps, you can specify a Table in any Python module:

    from piccolo.columns.reference import LazyTableReference
    
    class Band(Table):
        manager = ForeignKey(
            references=LazyTableReference(
               table_class_name="Manager",
               module_path="some_module.tables",
            )
            # Alternatively, Piccolo will interpret this string as
            # the same as above:
            # references="some_module.tables.Manager"
        )
    

  • on_delete

    Determines what the database should do when a row is deleted with foreign keys referencing it. If set to OnDelete.cascade, any rows referencing the deleted row are also deleted.

    Options:

    • OnDelete.cascade (default)

    • OnDelete.restrict

    • OnDelete.no_action

    • OnDelete.set_null

    • OnDelete.set_default

    To learn more about the different options, see the Postgres docs.

    from piccolo.columns import OnDelete
    
    class Band(Table):
        name = ForeignKey(
            references=Manager,
            on_delete=OnDelete.cascade
        )
    

  • on_update

    Determines what the database should do when a row has it’s primary key updated. If set to OnUpdate.cascade, any rows referencing the updated row will have their references updated to point to the new primary key.

    Options:

    • OnUpdate.cascade (default)

    • OnUpdate.restrict

    • OnUpdate.no_action

    • OnUpdate.set_null

    • OnUpdate.set_default

    To learn more about the different options, see the Postgres docs.

    from piccolo.columns import OnUpdate
    
    class Band(Table):
        name = ForeignKey(
            references=Manager,
            on_update=OnUpdate.cascade
        )
    

  • target_column

    By default the ForeignKey references the primary key column on the related table. You can specify an alternative column (it must have a unique constraint on it though). For example:

    # Passing in a column reference:
    ForeignKey(references=Manager, target_column=Manager.passport_number)
    
    # Or just the column name:
    ForeignKey(references=Manager, target_column='passport_number')
    

pylav.storage.database.tables.misc module

pylav.storage.database.tables.nodes module

class pylav.storage.database.tables.nodes.NodeRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

disabled_sources

Used for storing lists of data.

Example

class Ticket(Table):
    seat_numbers = Array(base_column=Integer())

# Create
>>> await Ticket(seat_numbers=[34, 35, 36]).save()

# Query
>>> await Ticket.select(Ticket.seat_numbers)
{'seat_numbers': [34, 35, 36]}
extras

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
managed

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
name

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
reconnect_attempts

Used for storing whole numbers. Uses the int type for values.

Example

class Band(Table):
    popularity = Integer()

# Create
>>> await Band(popularity=1000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000}
resume_key

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
resume_timeout

Used for storing whole numbers. Uses the int type for values.

Example

class Band(Table):
    popularity = Integer()

# Create
>>> await Band(popularity=1000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000}
search_only

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
ssl

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
yaml

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

class pylav.storage.database.tables.nodes.Sessions(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

bot

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
id

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
node

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
primary_key

Used for storing UUIDs - in Postgres a UUID column type is used, and in SQLite it’s just a Varchar. Uses the uuid.UUID type for values.

Example

import uuid

class Band(Table):
    uuid = UUID()

# Create
>>> await DiscountCode(code=uuid.uuid4()).save()

# Query
>>> await DiscountCode.select(DiscountCode.code)
{'code': UUID('09c4c17d-af68-4ce7-9955-73dcd892e462')}

pylav.storage.database.tables.player_state module

class pylav.storage.database.tables.player_state.PlayerStateRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

auto_play

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
auto_play_playlist_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
auto_shuffle

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
bot

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
channel_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
current

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

effect_enabled

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
effects

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

extras

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

forced_channel_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
history

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
notify_channel_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
paused

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
playing

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
position

An alias for Real.

primary_key

Used for storing UUIDs - in Postgres a UUID column type is used, and in SQLite it’s just a Varchar. Uses the uuid.UUID type for values.

Example

import uuid

class Band(Table):
    uuid = UUID()

# Create
>>> await DiscountCode(code=uuid.uuid4()).save()

# Query
>>> await DiscountCode.select(DiscountCode.code)
{'code': UUID('09c4c17d-af68-4ce7-9955-73dcd892e462')}
queue

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

repeat_current

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
repeat_queue

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
self_deaf

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
shuffle

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
text_channel_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
volume

Used for storing whole numbers. Uses the int type for values.

Example

class Band(Table):
    popularity = Integer()

# Create
>>> await Band(popularity=1000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000}

pylav.storage.database.tables.players module

class pylav.storage.database.tables.players.PlayerRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

alone_dc

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

alone_pause

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

auto_play

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
auto_play_playlist_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
auto_shuffle

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
bot

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
dj_roles

Used for storing lists of data.

Example

class Ticket(Table):
    seat_numbers = Array(base_column=Integer())

# Create
>>> await Ticket(seat_numbers=[34, 35, 36]).save()

# Query
>>> await Ticket.select(Ticket.seat_numbers)
{'seat_numbers': [34, 35, 36]}
dj_users

Used for storing lists of data.

Example

class Ticket(Table):
    seat_numbers = Array(base_column=Integer())

# Create
>>> await Ticket(seat_numbers=[34, 35, 36]).save()

# Query
>>> await Ticket.select(Ticket.seat_numbers)
{'seat_numbers': [34, 35, 36]}
effects

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

empty_queue_dc

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

extras

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

forced_channel_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
max_volume

Used for storing whole numbers. Uses the int type for values.

Example

class Band(Table):
    popularity = Integer()

# Create
>>> await Band(popularity=1000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000}
notify_channel_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
primary_key

Used for storing UUIDs - in Postgres a UUID column type is used, and in SQLite it’s just a Varchar. Uses the uuid.UUID type for values.

Example

import uuid

class Band(Table):
    uuid = UUID()

# Create
>>> await DiscountCode(code=uuid.uuid4()).save()

# Query
>>> await DiscountCode.select(DiscountCode.code)
{'code': UUID('09c4c17d-af68-4ce7-9955-73dcd892e462')}
repeat_current

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
repeat_queue

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
self_deaf

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
shuffle

Used for storing True / False values. Uses the bool type for values.

Example

class Band(Table):
    has_drummer = Boolean()

# Create
>>> await Band(has_drummer=True).save()

# Query
>>> await Band.select(Band.has_drummer)
{'has_drummer': True}
text_channel_id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
volume

Used for storing whole numbers. Uses the int type for values.

Example

class Band(Table):
    popularity = Integer()

# Create
>>> await Band(popularity=1000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000}

pylav.storage.database.tables.playlists module

class pylav.storage.database.tables.playlists.PlaylistRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

author

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
id

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
name

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
scope

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
tracks = <piccolo.columns.m2m.M2M object>
url

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}

pylav.storage.database.tables.queries module

class pylav.storage.database.tables.queries.QueryRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

identifier

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
info

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

last_updated

Used for storing timezone aware datetimes. Uses the datetime type for values. The values are converted to UTC in the database, and are also returned as UTC.

Example

import datetime

class Concert(Table):
    starts = Timestamptz()

# Create
>>> await Concert(
...    starts=datetime.datetime(
...        year=2050, month=1, day=1, tzinfo=datetime.timezone.tz
...    )
... ).save()

# Query
>>> await Concert.select(Concert.starts)
{
    'starts': datetime.datetime(
        2050, 1, 1, 0, 0, tzinfo=datetime.timezone.utc
    )
}
name

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
pluginInfo

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

tracks = <piccolo.columns.m2m.M2M object>

pylav.storage.database.tables.tracks module

class pylav.storage.database.tables.tracks.TrackRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

artworkUrl

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
encoded

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
async classmethod get_or_create(track)[source]
identifier

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
info

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

isrc

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
playlists = <piccolo.columns.m2m.M2M object>
pluginInfo

Used for storing JSON strings - Postgres only. The data is stored in a binary format, and can be queried. Insertion can be slower (as it needs to be converted to the binary format). The benefits of JSONB generally outweigh the downsides.

Parameters:

default – Either a JSON string can be provided, or a Python dict or list which is then converted to a JSON string.

queries = <piccolo.columns.m2m.M2M object>
sourceName

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
title

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}
uri

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}

pylav.storage.database.tables.version module

class pylav.storage.database.tables.version.BotVersionRow(_data=None, _ignore_missing=False, _exists_in_db=False, **kwargs)[source]

Bases: Table

bot

In Postgres, this column supports large integers. In SQLite, it’s an alias to an Integer column, which already supports large integers. Uses the int type for values.

Example

class Band(Table):
    value = BigInt()

# Create
>>> await Band(popularity=1000000).save()

# Query
>>> await Band.select(Band.popularity)
{'popularity': 1000000}
version

Use when you want to store large strings, and don’t want to limit the string size. Uses the str type for values.

Example

class Band(Table):
    name = Text()

# Create
>>> await Band(name='Pythonistas').save()

# Query
>>> await Band.select(Band.name)
{'name': 'Pythonistas'}

Module contents