API Reference

As of v2.0.0, this module comes with an API to communicate with TibiaWiki or with the elements of the generated database.

TibiaWiki

The following are classes used to communicate with TibiaWiki through its MediaWiki API.

WikiClient

class tibiawikisql.WikiClient[source]

Contains methods to communicate with TibiaWiki’s API.

classmethod get_category_members(name, skip_index=True)[source]

Create a generator that obtains entries in a certain category.

Parameters
  • name (str) – The category’s name. Category: prefix is not necessary.

  • skip_index (bool) – Whether to skip index articles or not.

Yields

WikiEntry – Articles in this category.

classmethod get_category_members_titles(name, skip_index=True)[source]

Create a generator that obtains a list of article titles in a category.

Parameters
  • name (str) – The category’s name. Category: prefix is not necessary.

  • skip_index (bool) – Whether to skip index articles or not.

Yields

str – Titles of articles in this category.

classmethod get_image_info(name)[source]

Get an image’s info.

It is not required to prefix the name with File:, but the extension is required.

Parameters

name (str) – The name of the image.

Returns

The image’s information.

Return type

Image

classmethod get_images_info(names)[source]

Get the information of a list of image names.

It is not required to prefix the name with File:, but the extension is required.

Warning

The order of the returned images might not match the order of the provided names due to an API limitation.

Parameters

names (list of str) – A list of names of images to get the info of.

Yields

Image – An image’s information.

classmethod get_articles(names)[source]

Create a generator that obtains a list of articles given their titles.

Warning

The order of the returned articles might not match the order of the provided names due to an API limitation.

Parameters

names (list of str) – A list of names of articles to get the info of.

Yields

Article – An article in the list of names.

classmethod get_article(name)[source]

Get an article’s info.

Parameters

name (str) – The name of the Article.

Returns

The article matching the title.

Return type

Article

WikiEntry

class tibiawikisql.WikiEntry[source]

A TibiaWiki entry.

This is a partial object that is obtained when fetching category members.

The following classes implement this:

article_id

The entry’s id.

Type

int

title

The entry’s title.

Type

str

timestamp

The date of the entry’s last edit, represented as a unix timestamp.

Type

int

property url

The URL to the article’s display page.

Type

str

Article

class tibiawikisql.Article[source]

Represents a text article.

article_id

The article’s internal id.

Type

int

title

The article’s title.

Type

str

timestamp

The date of the entry’s last edit, represented as a unix timestamp.

Type

int

content

The article’s source content.

Type

str

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

property url

The URL to the article’s display page.

Type

str

Image

class tibiawikisql.Image[source]

Represents an image info.

article_id

The image’s internal id.

Type

int

title

The image’s title.

Type

str

timestamp

The date of the entry’s last edit, represented as a unix timestamp.

Type

int

file_url

The image’s url.

Type

str

property extension

The image’s file extension.

Type

str

property file_name

The image’s file name.

Type

str

property clean_name

The image’s name without extension and prefix.

Type

str

property url

The URL to the article’s display page.

Type

str

Abstract Base Classes

This classes are used to implemenent common functionality among different classes.

Row

class tibiawikisql.models.Row[source]

An abstract base class implemented to indicate that the Model represents a SQL row.

table

The SQL table where this model is stored.

Type

database.Table

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)[source]

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)[source]

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)[source]

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

Parseable

class tibiawikisql.models.Parseable[source]

An abstract base class with the common parsing operations.

This class is inherited by Models that are parsed directly from a TibiaWiki article.

Classes implementing this must override map

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

classmethod from_article(article)[source]

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

property url

The URL to the article’s display page.

Type

str

Models

Achievement

class tibiawikisql.models.Achievement[source]

Represents an Achievement.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The achievement’s name.

Type

str

grade

The achievement’s grade, from 1 to 3. Also know as ‘stars’.

Type

int

points

The amount of points given by this achievement.

Type

int

description

The official description shown for the achievement.

Type

str

spoiler

Instructions or information on how to obtain the achievement.

Type

str

secret

Whether the achievement is secret or not.

Type

bool

premium

Whether a premium account is required to get this achievement.

Type

bool

achievement_id

The internal ID of the achievement.

Type

int

status

The status of this achievement in the game.

Type

str

version

The client version where this was first implemented.

Type

str

classmethod from_article(article)

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Achievement

property url

The URL to the article’s display page.

Type

str

Book

class tibiawikisql.models.Book[source]

Represents a book or written document in Tibia.

Parameters
  • article_id (int) – The ID of the article that contains this book.

  • title (str) – The title of the article containing this book.

  • name (:class:´str´) – The name of the book.

  • book_type (str) – The type of item this book can be found in.

  • item_id (int) – The ID of the item this book is written in.

  • location (str) – Where the book can be found.

  • blurb (str) – A short introduction text of the book.

  • author (str) – The person that wrote the book, if known.

  • prev_book (str) – If the book is part of a series, the book that precedes this one.

  • next_book (str) – If the book is part of a series, the book that follows this one.

  • text (str) – The content of the book.

  • version (str) – The client version where this item was first implemented.

  • status (str) – The status of this item in the game.

  • timestamp (int) – The last time the containing article was edited.

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_article(article)

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Book

property url

The URL to the article’s display page.

Type

str

Charm

class tibiawikisql.models.Charm[source]

Represents a charm.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The name of the charm.

Type

str

type

The type of the charm.

Type

str

effect

The charm’s description.

Type

str

cost

The number of charm points needed to unlock.

Type

int

version

The client version where this creature was first implemented.

Type

str

status

The status of this charm in the game.

Type

str

image

The charm’s icon.

Type

bytes

classmethod from_article(article)

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Charm

property url

The URL to the article’s display page.

Type

str

Creature

class tibiawikisql.models.Creature[source]

Represents a creature.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

article

The article that goes before the name when looking at the creature.

Type

str

name

The name of the creature, as displayed in-game.

Type

str

plural

The plural of the name.

Type

str

library_race

The race name of the creature in Tibia.com’s library.

Type

str

creature_class

The creature’s classification.

Type

str

creature_type

The creature’s type.

Type

str

type_secondary

The creature’s secondary type, if any.

Type

str

bestiary_class

The creature’s bestiary class, if applicable.

Type

str

bestiary_level

The creature’s bestiary level, from ‘Trivial’ to ‘Hard’

Type

str

bestiary_occurrence

The creature’s bestiary occurrence, from ‘Common’ to ‘Very Rare’.

Type

str

hitpoints

The creature’s hitpoints, may be None if unknown.

Type

int

experience

Experience points yielded by the creature. Might be None if unknown.

Type

int

armor

The creature’s armor value.

Type

int

speed

The creature’s speed value.

Type

int

runs_at

The amount of hitpoints when the creature starts to run away. 0 means it won’t run away.

Type

int

summon_cost

The mana needed to summon this creature. 0 if not summonable.

Type

int

convince_cost

The mana needed to convince this creature. 0 if not convincible.

Type

int

illusionable

Whether the creature can be illusioned into using Creature Illusion.

Type

bool

pushable

Whether the creature can be pushed or not.

Type

bool

push_objects

Whether the creature can push objects or not.

Type

bool

sees_invisible

Whether the creature can see invisible players or not.

Type

bool

paralysable

Whether the creature can be paralyzed or not.

Type

bool

boss

Whether the creature is a boss or not.

Type

bool

modifier_physical

The percentage of damage received of physical damage. None if unknown.

Type

int

modifier_earth

The percentage of damage received of earth damage. None if unknown.

Type

int

modifier_fire

The percentage of damage received of fire damage. None if unknown.

Type

int

modifier_energy

The percentage of damage received of energy damage. None if unknown.

Type

int

modifier_ice

The percentage of damage received of ice damage. None if unknown.

Type

int

modifier_death

The percentage of damage received of death damage. None if unknown.

Type

int

modifier_holy

The percentage of damage received of holy damage. None if unknown.

Type

int

modifier_drown

The percentage of damage received of drown damage. None if unknown.

Type

int

modifier_lifedrain

The percentage of damage received of life drain damage. None if unknown.

Type

int

modifier_healing

The healing modifier. None if unknown.

Type

int

abilities

A list of the creature abilities.

Type

list of CreatureAbility

max_damage

The maximum damage the creature can make.

Type

CreatureMaxDamage

walks_through

The field types the creature will walk through, separated by commas.

Type

str

walks_around

The field types the creature will walk around, separated by commas.

Type

str

location

The locations where the creature can be found.

Type

str

version

The client version where this creature was first implemented.

Type

str

status

The status of this creature in the game.

Type

str

image

The creature’s image in bytes.

Type

bytes

loot

The items dropped by this creature.

Type

list of CreatureDrop

property bestiary_kills: Optional[int]

Total kills needed to complete the bestiary entry if applicable.

Type

int, optional

property charm_points: Optional[int]

Charm points awarded for completing the creature’s bestiary entry, if applicable.

Type

int, optional

property elemental_modifiers

Returns a dictionary containing all elemental modifiers, sorted in descending order.

Type

OrderedDict

property immune_to: List[str]

Gets a list of the elements the creature is immune to.

Type

list of str

property weak_to

Dictionary containing the elements the creature is weak to and modifier.

Type

OrderedDict

property resistant_to

Dictionary containing the elements the creature is resistant to and modifier.

Type

OrderedDict

classmethod from_article(article)[source]

Parse an article into a TibiaWiki model.

This method is overridden to parse extra attributes like loot.

Parameters

article (api.Article) – The article from where the model is parsed.

Returns

The creature represented by the current article.

Return type

Creature

insert(c)[source]

Insert the current model into its respective database.

This method is overridden to insert elements of child rows.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod get_by_field(c, field, value, use_like=False)[source]

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Creature

property url

The URL to the article’s display page.

Type

str

CreatureAbility

class tibiawikisql.models.CreatureAbility[source]

Represents a creature’s ability.

creature_id

The article ID of the creature this ability belongs to.

Type

int

name

The name of the ability.

Type

str

effect

The effect of the ability, or the damage range.

Type

str

element

The element of damage type of the ability. This could also be a status condition instead. For abilities that are just plain text, plain_text is set. For abilities that are not using the abilities templates in TibiaWiki, they are saved as a single entry with element: no_template.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.CreatureAbility

CreatureMaxDamage

class tibiawikisql.models.CreatureMaxDamage[source]

Represent a creature’s max damage, broke down by damage type.

creature_id

The article ID of the creature this max damage belongs to.

Type

int

physical

The maximum physical damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

fire

The maximum fire damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

ice

The maximum ice damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

earth

The maximum earth damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

energy

The maximum energy damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

holy

The maximum holy damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

death

The maximum death damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

drown

The maximum drown damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

lifedrain

The maximum life drain damage dealt by the creature. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

manadrain

The maximum mana drain damage dealt by the creature. This is not counted as part of the total. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

summons

The maximum damage dealt by the creature’s summons. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

total

The maximum damage the creature can deal in a single turn. This doesn’t count manadrain and summon damage. In most cases, this is simply the sum of the other damages, but in some cases, the amount may be different. If it is unknown, but the creature does deal damage, it will be -1.

Type

int, optional

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.CreatureMaxDamage

CreatureSound

class tibiawikisql.models.CreatureSound[source]

Represents a sound made by a creature.

creature_id

The article id of the creature that does this sound.

Type

int

content

The content of the sound.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.CreatureSound

House

class tibiawikisql.models.House[source]

Represents a house or guildhall.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

house_id

The house’s id on tibia.com.

Type

int

name

The name of the house.

Type

str

guildhall

Whether the house is a guildhall or not.

Type

bool

city

The city where the house is located.

Type

str

street

The name of the street where the house is located.

Type

str

location

A brief description of where the house is.

Type

str

beds

The maximum number of beds the house can have.

Type

int

rent

The monthly rent of the house.

Type

int

size

The number of tiles (SQM) of the house.

Type

int

rooms

The number of rooms the house has.

Type

int

floors

The number of floors the house has.

Type

int

x

The x coordinate of the house.

Type

int

y

The y coordinate of the house.

Type

int

z

The z coordinate of the house.

Type

int

status

The status of this house in the game.

Type

str

version

The client version where this creature was first implemented.

Type

str

classmethod from_article(article)

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.House

property url

The URL to the article’s display page.

Type

str

Imbuement

class tibiawikisql.models.Imbuement[source]

Represents an imbuement type.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The name of the imbuement.

Type

str

tier

The tier of the imbuement.

Type

str

type

The imbuement’s type.

Type

str

effect

The effect given by the imbuement.

Type

str

slots

The type of items this imbuement may be applied on.

Type

str

version

The client version where this imbuement was first implemented.

Type

str

status

The status of this imbuement the game.

Type

str

image

The bytes of the imbuement’s image.

Type

str

materials

The materials needed for the imbuement.

Type

list of ImbuementMaterial

classmethod from_article(article)[source]

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod get_by_field(c, field, value, use_like=False)[source]

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Imbuement

property url

The URL to the article’s display page.

Type

str

ImbuementMaterial

class tibiawikisql.models.ImbuementMaterial[source]

Represents a item material for an imbuement.

imbuement_id

The article id of the imbuement this material belongs to.

Type

int

imbuement_title

The title of the imbuement this material belongs to.

Type

str

item_id

The article id of the item material.

Type

int

item_title

The title of the item material.

Type

str

amount

The amount of items required.

Type

int

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.ImbuementMaterial

Item

class tibiawikisql.models.Item[source]

Represents an Item.

id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The in-game name of the item.

Type

str

plural

The plural of the name.

Type

str

article

The article that goes before the name when looking at the item.

Type

str

marketable

Whether the item can be traded on the Market or not.

Type

bool

stackable

Whether the item can be stacked or not.

Type

bool

pickupable

Whether the item can be picked up or not.

Type

bool

value_sell

The highest price an NPC will buy this item for.

Type

int

value_buy

The lowest price an NPC will sell this item for.

Type

int

weight

The item’s weight in ounces.

Type

float

item_class

The item class the item belongs to.

Type

str

item_type

The item’s type.

Type

str

type_secondary

The item’s secondary type, if any.

Type

str

flavor_text

The extra text that is displayed when some items are looked at.

Type

str

light_color

The color of the light emitted by this item in RGB, if any.

Type

int, optional.

light_radius

The radius of the light emitted by this item, if any.

Type

int

client_id

The internal id of the item in the client.

Type

int

version

The client version where this item was first implemented.

Type

str

status

The status of this item in the game.

Type

str

image

The item’s image in bytes.

Type

bytes

attributes

The item’s attributes.

Type

list of ItemAttribute

dropped_by

List of creatures that drop this item, with the chances.

Type

list of CreatureDrop

sold_by

List of NPCs that sell this item.

Type

list of NpcSellOffer

bought_by

List of NPCs that buy this item.

Type

list of NpcBuyOffer

awarded_in

List of quests that give this item as reward.

Type

list of QuestReward

sounds

List of sounds made when using the item.

Type

list of ItemSound.

property attributes_dict

A mapping of the attributes this item has.

Type

dict

property resistances

A mapping of the elemental resistances of this item.

Type

collections.OrderedDict

property look_text

The item’s look text.

Type

str

classmethod from_article(article)[source]

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod get_by_field(c, field, value, use_like=False)[source]

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Item

property url

The URL to the article’s display page.

Type

str

ItemAttribute

class tibiawikisql.models.ItemAttribute[source]

Represents an Item’s attribute.

item_id

The id of the item the attribute belongs to

Type

int

name

The name of the attribute.

Type

str

value

The value of the attribute.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.ItemAttribute

ItemStoreOffer

class tibiawikisql.models.ItemStoreOffer[source]

Represents an offer for an item on the Tibia Store.

item_id

The ID of the item this offer is for.

Type

int

price

The price of the item.

Type

int

amount

The amount of the item.

Type

int

currency

The currency used. In most of the times it is Tibia Coins.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.ItemStoreOffer

Key

class tibiawikisql.models.Key[source]

Represents a key item.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The name of the creature, as displayed in-game.

Type

str

number

The key’s number.

Type

int

item_id

The article id of the item this key is based on.

Type

int

material

The key’s material.

Type

str

location

The key’s location.

Type

str

notes

Notes about the key.

Type

str

origin

Notes about the origin of the key.

Type

str

status

The status of this key in the game.

Type

str

version

The client version where this creature was first implemented.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_article(article)

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.ItemKey

property url

The URL to the article’s display page.

Type

str

Npc

class tibiawikisql.models.Npc[source]

Represents a non-playable character.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The in-game name of the NPC.

Type

str

gender

The gender of the NPC.

Type

str

races

The races of the NPC.

Type

list of str

jobs

The jobs of the NPC.

Type

list of str

location

The location of the NPC.

Type

str

city

The nearest city to where the NPC is located.

Type

str

x

The x coordinates of the NPC.

Type

int

y

The y coordinates of the NPC.

Type

int

z

The z coordinates of the NPC.

Type

int

version

The client version where the NPC was implemented.

Type

str

status

The status of this NPC in the game.

Type

str

image

The NPC’s image in bytes.

Type

bytes

sell_offers

Items sold by the NPC.

Type

list of NpcSellOffer

buy_offers

Items bought by the NPC.

Type

list of NpcBuyOffer

destinations

Places where the NPC can travel to.

Type

list of NpcDestination

teaches

Spells this NPC can teach.

Type

list of NpcSpell

property job

Get the first listed job of the NPC, if any.

Type

str

property race

Get the first listed race of the NPC, if any.

Type

str

classmethod from_article(article)[source]

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod get_by_field(c, field, value, use_like=False)[source]

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Npc

property url

The URL to the article’s display page.

Type

str

NpcDestination

class tibiawikisql.models.NpcDestination[source]

Represents a NPC’s travel destination.

npc_id

The article id of the NPC.

Type

int

name

The name of the destination

Type

str

price

The price in gold to travel.

Type

int

notes

Notes about the destination, such as requirements.

Type

str

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.NpcDestination

NpcBuyOffer

class tibiawikisql.models.NpcBuyOffer[source]

Represents an item buyable by an NPC.

npc_id

The article id of the npc that buys the item.

Type

int

npc_title

The title of the npc that buys the item.

Type

str

npc_city

The city where the NPC is located.

Type

str

item_id

The id of the item bought by the npc.

Type

int

item_title

The title of the item bought by the npc.

Type

str

currency_id

The item id of the currency used to sell the item.

Type

int

currency_title

The title of the currency used to sell the item

Type

str

value

The value of the item in the specified currency.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.NpcBuying

NpcSellOffer

class tibiawikisql.models.NpcSellOffer[source]

Represents an item sellable by an NPC.

npc_id

The article id of the npc that sells the item.

Type

int

npc_title

The title of the npc that sells the item.

Type

str

npc_city

The city where the NPC is located.

Type

str

item_id

The id of the item sold by the npc.

Type

int

item_title

The title of the item sold by the npc.

Type

str

currency_id

The item id of the currency used to buy the item.

Type

int

currency_title

The title of the currency used to buy the item

Type

str

value

The value of the item in the specified currency.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.NpcSelling

NpcSpell

class tibiawikisql.models.NpcSpell[source]

Represents a spell that a NPC can teach.

npc_id

The article id of the npc that teaches the spell.

Type

int

npc_title

The title of the npc that teaches the spell.

Type

str

spell_id

The article id of the spell taught by the npc.

Type

int

spell_title

The title of the spell taught by the npc.

Type

str

price

The price paid to have this spell taught.

Type

int

npc_city

The city where the NPC is located.

Type

str

knight

If the spell is taught to knights.

Type

bool

paladin

If the spell is taught to paladins.

Type

bool

druid

If the spell is taught to druids.

Type

bool

sorcerer

If the spell is taught to sorcerers.

Type

bool

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.NpcSpell

Outfit

class tibiawikisql.models.Outfit[source]

Represents an outfit.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The name of the outfit.

Type

str

type

The type of outfit. Basic, Quest, Special, Premium.

Type

str

premium

Whether the outfit requires a premium account or not.

Type

bool

bought

Whether the outfit can be bought from the Store or not.

Type

bool

tournament

Whether the outfit can be bought with Tournament coins or not.

Type

bool

full_price

The full price of this outfit in the Tibia Store.

Type

int

achievement

The achievement obtained for acquiring this full outfit.

Type

str

status

The status of this outfit in the game.

Type

str

version

The client version where this outfit was first implemented.

Type

str

images

The outfit’s images.

Type

list of OutfitImage

quests

Quests that grant the outfit or its addons.

Type

list of OutfitQuest

classmethod from_article(article)[source]

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod get_by_field(c, field, value, use_like=False)[source]

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Outfit

property url

The URL to the article’s display page.

Type

str

OutfitImage

class tibiawikisql.models.OutfitImage[source]

Represents an outfit image.

outfit_id

The article id of the outfit the image belongs to.

Type

int

outfit_name

The name of the outfit.

Type

str

sex

The sex the outfit is for.

Type

str

addon

The addons represented by the image. 0 for no addons, 1 for first addon, 2 for second addon and 3 for both addons.

Type

int

image

The outfit’s image in bytes.

Type

bytes

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.OutfitImage

OutfitQuest

class tibiawikisql.models.OutfitQuest[source]

Represents a quest that grants an outfit or it’s addon.

outfit_id

The article id of the outfit given.

Type

int

outfit_title

The title of the outfit given.

Type

str

quest_id

The article id of the quest that gives the outfit or its addons.

Type

int

quest_title

The title of the quest.

Type

str

type

Whether the quest is for the outfit or addons.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.OutfitQuest

Quest

class tibiawikisql.models.Quest[source]

Represents a quest.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The name of the quest.

Type

str

location

The location of the quest.

Type

str

rookgaard

Whether this quest is in Rookgaard or not.

Type

bool

type

The type of quest.

Type

str

quest_log

Whether this quest is registered in the quest log or not.

Type

bool

legend

The legend of the quest.

Type

str

level_required

The level required to finish the quest.

Type

int

The recommended level to finish the quest.

Type

int

active_time

Times of the year when this quest is active.

Type

str

estimated_time

Estimated time to finish this quest.

Type

str:

status

The status of this quest in the game.

Type

str

version

The client version where this outfit was first implemented.

Type

str

dangers

Creatures found in the quest.

Type

list of QuestDanger

rewards

Items rewarded in the quest.

Type

list of QuestReward

classmethod from_article(article)[source]

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod get_by_field(c, field, value, use_like=False)[source]

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Quest

property url

The URL to the article’s display page.

Type

str

QuestDanger

class tibiawikisql.models.QuestDanger[source]

Represents a creature found in the quest.

quest_id

The article id of the quest.

Type

int

quest_title

The title of the quest.

Type

str

creature_id

The article id of the found creature.

Type

int

creature_title

The title of the found creature.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.QuestDanger

QuestReward

class tibiawikisql.models.QuestReward[source]

Represents an item obtained in the quest.

quest_id

The article id of the quest.

Type

int

quest_title

The title of the quest.

Type

str

item_id

The article id of the rewarded item.

Type

int

item_title

The title of the rewarded item.

Type

str

insert(c)[source]

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.QuestReward

RashidPosition

class tibiawikisql.models.RashidPosition[source]

Represents a Rashid position.

day

Day of the week, Monday starts at 0.

Type

int

x

The x coordinate of Rashid that day.

Type

int

y

The y coordinate of Rashid that day.

Type

int

z

The z coordinate of Rashid that day.

Type

int

city

The city where Rashid is that day.

Type

str

location

The location where Rashid is that day.

Type

str

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.RashidPosition

Spell

class tibiawikisql.models.Spell[source]

Represents a Spell.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The name of the spell.

Type

str

words

The spell’s invocation words.

Type

str

effect

The effects of casting the spell.

Type

str

type

The spell’s type.

Type

str

group_spell

The spell’s group.

Type

str

group_secondary

The spell’s secondary group.

Type

str

group_rune

The group of the rune created by this spell.

Type

str

element

The element of the damage made by the spell.

Type

str

mana

The mana cost of the spell

Type

int

soul

The soul cost of the spell.

Type

int

price

The gold cost of the spell.

Type

int

cooldown

The spell’s individual cooldown in seconds.

Type

int

cooldown_group

The spell’s group cooldown in seconds. The time you have to wait before casting another spell in the same group.

Type

int

cooldown_group_secondary

The spell’s secondary group cooldown.

Type

int

level

The level required to use the spell.

Type

int

premium

Whether the spell is premium only or not.

Type

bool

promotion

Whether you need to be promoted to buy or cast this spell.

Type

bool

knight

Whether the spell can be used by knights or not.

Type

bool

paladin

Whether the spell can be used by paladins or not.

Type

bool

druid

Whether the spell can be used by druids or not.

Type

bool

sorcerer

Whether the spell can be used by sorcerers or not.

Type

bool

taught_by

NPCs that teach this spell.

Type

list of NpcSpell

status

The status of this spell in the game.

Type

str

version

The client version where the spell was implemented.

Type

str

image

The spell’s image in bytes.

Type

bytes

classmethod from_article(article)[source]

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

classmethod get_by_field(c, field, value, use_like=False)[source]

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Spell

property url

The URL to the article’s display page.

Type

str

Update

class tibiawikisql.models.Update[source]

Represents a game update.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The name of the update, if any.

Type

str

news_id

The id of the news article that announced the release.

Type

str

type_primary

The primary type of the update.

Type

str

type_secondary

The secondary type of the update.

Type

str

previous

The version before this update.

Type

str

next

The version after this update.

Type

str

version

The version set by this update.

Type

str

summary

A brief summary of the update.

Type

str

changelist

A brief list of the changes introduced.

Type

str

classmethod from_article(article)

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.Update

property url

The URL to the article’s display page.

Type

str

World

class tibiawikisql.models.World[source]

Represents a Game World.

article_id

The id of the containing article.

Type

int

title

The title of the containing article.

Type

str

timestamp

The last time the containing article was edited.

Type

int

name

The name of the world.

Type

str

pvp_type

The world’s PvP type.

Type

str

location

The world’s server’s physical location.

Type

str

preview

Whether the world is a preview world or not.

Type

bool

experimental

Whether the world is a experimental world or not.

Type

bool

online_since

Date when the world became online for the first time, in ISO 8601 format.

Type

str

offline_since

Date when the world went offline, in ISO 8601 format.

Type

str, optional

merged_into

The name of the world this world got merged into, if applicable.

Type

str, optional.

battleye

Whether the world is BattlEye protected or not.

Type

bool

battleye_type

The type of BattlEye protection the world has. Can be either green or yellow.

Type

bool

protected_since

Date when the world started being protected by BattlEye, in ISO 8601 format.

Type

str

world_board

The board ID for the world’s board.

Type

int

trade_board

The board ID for the world’s trade board.

Type

int

classmethod from_article(article)

Parse an article into a TibiaWiki model.

Parameters

article (Article) – The article from where the model is parsed.

Returns

An inherited model object for the current article.

Return type

abc.Parseable

classmethod from_row(row)

Return an instance of the model from a row or dictionary.

Parameters

row (dict, sqlite3.Row) – A dict representing a row or a Row object.

Returns

An instance of the class, based on the row.

Return type

cls

classmethod get_by_field(c, field, value, use_like=False)

Get an element by a specific field’s value.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str) – The field to filter with.

  • value – The value to look for.

  • use_like (bool) – Whether to use LIKE as a comparator instead of =.

Returns

The object found, or None.

Return type

cls

Raises

ValueError – The specified field doesn’t exist in the table.

property infobox_attributes

Returns a mapping of the template attributes.

Type

dict

insert(c)

Insert the current model into its respective database table.

Parameters

c (sqlite3.Cursor, sqlite3.Connection) – A cursor or connection of the database.

classmethod search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Find elements matching the provided values.

If no values are provided, it will return all elements.

Note that this won’t get values found in child tables.

Parameters
  • c (sqlite3.Connection, sqlite3.Cursor) – A connection or cursor of the database.

  • field (str, optional) – The field to filter by.

  • value (optional) – The value to filter by.

  • use_like (bool, optional) – Whether to use LIKE as a comparator instead of =.

  • sort_by (str, optional) – The column to sort by.

  • ascending (bool, optional) – Whether to sort ascending or descending.

Returns

A list containing all matching objects.

Return type

list of cls

Raises

ValueError – The specified field doesn’t exist in the table.

table

alias of tibiawikisql.schema.World

property url

The URL to the article’s display page.

Type

str

Utility Functions

tibiawikisql.utils.clean_question_mark(content)[source]

Remove question mark strings, turning them to nulls.

Parameters

content (str) – A string to clean.

Returns

The string, or None if it was a question mark.

Return type

str

Remove any links from the string, changing them for their plan version.

Parameters

content (str) – The string to clean.

Returns

The clean string, with no links.

Return type

str

tibiawikisql.utils.convert_tibiawiki_position(pos)[source]

Convert from TibiaWiki position system to regular numeric coordinates.

TibiaWiki takes the coordinates and splits in two bytes, represented in decimal, separated by a period.

Parameters

pos (str) – A string containing a coordinate.

Returns

The coordinate value.

Return type

int

tibiawikisql.utils.find_template(content: str, template_name, partial=False, recursive=False)[source]

Find a template in a string containing wiki code.

If there are multiple matches, the first one will be returned.

Parameters
  • content (str) – A string containing wiki code.

  • template_name (str) – The name of the template to match. Case insensitive.

  • partial (bool) –

    Whether to match the entire template name or just a substring of it.

    e.g. match “Loot Table” when searching for “Loot”

  • recursive (bool) – Whether to search for templates recursively, by going inside nested templates.

Returns

The first template found in the content, if any. Otherwise None is returned.

Return type

Template

tibiawikisql.utils.find_templates(content: str, template_name, partial=False, recursive=False)[source]

Create a generator to find templates a wikicode string.

Parameters
  • content (str) – A string containing wiki code.

  • template_name (str) – The name of the template to match. Case insensitive.

  • partial (bool) –

    Whether to match the entire template name or just a substring of it.

    e.g. match “Loot Table” when searching for “Loot”

  • recursive (bool) – Whether to search for templates recursively, by going inside nested templates.

Yields

Template – Templates matching provided string.

tibiawikisql.utils.parse_boolean(value: str, default=False, invert=False)[source]

Parse a boolean value from a string.

String must contain “yes” to be considered True.

Parameters
  • value (str) – The string containing an integer.

  • default (bool, optional) – The value to return if no boolean string is found.

  • invert (bool, optional) – Whether to invert the value or not.

Returns

The boolean value parsed in the string, or default if it doesn’t match yes or no.

Return type

bool

tibiawikisql.utils.parse_date(value)[source]

Parse a date from the formats used in TibiaWiki.

  • June 28, 2019

  • Aug 21, 2014

Parameters

value (str) – The string containing the date.

Returns

The date represented by the string.

Return type

datetime.date

tibiawikisql.utils.parse_float(value, default=0.0)[source]

From a string, parses a floating value.

Parameters
  • value (str) – The string containing the floating number.

  • default (float, optional) – The value to return if no float is found.

Returns

The floating number found, or the default value provided.

Return type

float

tibiawikisql.utils.parse_integer(value, default=0)[source]

Parse an integer from a string. Extra characters are ignored.

Parameters
  • value (str) – The string containing an integer.

  • default (int, optional) – The value to return if no integer is found.

Returns

The numeric value found, or the default value provided.

Return type

int

tibiawikisql.utils.parse_loot_statistics(value)[source]

Get every dropped item from a creature’s loot statistics.

Parameters

value (str) – A string containing a creature’s loot statistics.

Returns

A tuple containing the total kills and a list of entries.

Return type

tuple

tibiawikisql.utils.parse_min_max(value)[source]

Parse the mininum and maximum amounts of a loot drop.

They consist of two numbers separated by a hyphen, e.g. 0-40

Parameters

value (str) – A string containing minimum and maximum values.

Returns

The minimum and maximum amounts.

Return type

tuple

tibiawikisql.utils.parse_sounds(value)[source]

Parse a list of sounds, using Template:Sound_List.

Parameters

value (str) – A string containing the list of sounds.

Returns

A list of sounds.

Return type

list

tibiawikisql.utils.client_color_to_rgb(value: int)[source]

Convert a color number from Tibia’s client data to a RGB value.

Parameters

value (int) – A numeric value representing a color.

Returns

The hexadecimal color represented.

Return type

int

tibiawikisql.utils.parse_templatates_data(content)[source]

Parse the attributes of an Infobox template.

Parameters

content (str) – A string containing an Infobox template.

Returns

A dictionary with every attribute as key.

Return type

dict[str, str]

tibiawikisql.utils.strip_code(value)[source]

Strip code from Wikicode elements into plain strings.

Parameters

value – A string or object containing wiki code.

Returns

A string representing the plain text content.

Return type

str