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]

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]

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]

Gets 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]

Gets 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 articles might not match the order of the provided names due to an API limitation.

Parameters

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

Yields

Image – An image’s information.

classmethod get_articles(names)[source]

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[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]

Gets 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 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]

Inserts 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]

Returns 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]

Gets 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]

Finds 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]

Parses 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

Type[abc.Parseable]

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

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)

Parses 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

Type[abc.Parseable]

classmethod from_row(row)

Returns 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)

Gets 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)

Inserts 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)

Finds 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.

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)

Parses 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

Type[abc.Parseable]

classmethod from_row(row)

Returns 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)

Gets 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)

Inserts 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)

Finds 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.

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

creature_class

The creature’s classification.

Type

str

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

max_damage

The maximum amount of damage the creature can do in a single turn.

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

abilities

A brief description of the creature’s abilities.

Type

str

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

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

Total kills needed to complete the bestiary entry if applicable.

Type

int, optional

property charm_points

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

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]

Parses 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]

Inserts 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]

Gets 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)

Returns 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 search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Finds 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.

property url

The URL to the article’s display page.

Type

str

CreatureDrop

class tibiawikisql.models.CreatureDrop[source]

Represents an item dropped by a creature.

creature_id

The article id of the creature the drop belongs to.

Type

int

creature_title

The title of the creature that drops the item.

Type

str

item_id

The article id of the item.

Type

int

item_title

The title of the dropped item.

Type

str

min

The minimum possible amount of the dropped item.

Type

int

max

The maximum possible amount of the dropped item.

Type

int

chance

The chance percentage of getting this item dropped by this creature.

Type

float

insert(c)[source]

Inserts the current model into its respective database.

Overridden to insert using a subquery to get the item’s id from the name.

Parameters

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

classmethod from_row(row)

Returns 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)

Gets 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)

Finds 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.

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)

Parses 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

Type[abc.Parseable]

classmethod from_row(row)

Returns 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)

Gets 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)

Inserts 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)

Finds 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.

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

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]

Parses 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

Type[abc.Parseable]

insert(c)[source]

Inserts 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]

Gets 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)

Returns 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 search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Finds 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.

property url

The URL to the article’s display page.

Type

str

ImbuementMaterial

class tibiawikisql.models.ImbuementMaterial[source]

Representes 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]

Inserts 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)

Returns 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)

Gets 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)

Finds 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.

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

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]

Parses 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

Type[abc.Parseable]

insert(c)[source]

Inserts 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]

Gets 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)

Returns 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 search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Finds 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.

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]

Inserts 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)

Returns 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)

Gets 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)

Finds 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.

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]

Inserts 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)

Parses 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

Type[abc.Parseable]

classmethod from_row(row)

Returns 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)

Gets 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)

Finds 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.

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

race

The race of the NPC.

Type

str

job

The NPC’s job.

Type

str

location

The location of the NPC.

Type

str

city

The city 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 NpcSellOffer

teaches

Spells this NPC can teach.

Type

list of NpcSpell

classmethod from_article(article)[source]

Parses 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

Type[abc.Parseable]

insert(c)[source]

Inserts 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]

Gets 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)

Returns 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 search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Finds 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.

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)

Returns 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)

Gets 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)

Inserts 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)

Finds 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.

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]

Inserts 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)

Returns 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)

Gets 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)

Finds 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.

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]

Inserts 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)

Returns 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)

Gets 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)

Finds 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.

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]

Inserts 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)

Returns 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)

Gets 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)

Finds 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.

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]

Parses 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

Type[abc.Parseable]

insert(c)[source]

Inserts 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]

Gets 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)

Returns 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 search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Finds 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.

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)

Returns 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)

Gets 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)

Inserts 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)

Finds 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.

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]

Inserts 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)

Returns 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)

Gets 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)

Finds 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.

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]

Parses 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

Type[abc.Parseable]

insert(c)[source]

Inserts 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]

Gets 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)

Returns 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 search(c, field=None, value=None, use_like=False, sort_by=None, ascending=True)

Finds 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.

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]

Inserts 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)

Returns 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)

Gets 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)

Finds 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.

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]

Inserts 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)

Returns 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)

Gets 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)

Finds 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.

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)

Returns 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)

Gets 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)

Inserts 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)

Finds 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.

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

class

The spell’s class.

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 cooldown in seconds.

Type

int

level

The level required to use the spell.

Type

int

premium

Whether the spell is premium only or not.

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]

Parses 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

Type[abc.Parseable]

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

Gets 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)

Returns 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

insert(c)

Inserts 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)

Finds 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.

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

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)

Parses 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

Type[abc.Parseable]

classmethod from_row(row)

Returns 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)

Gets 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)

Inserts 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)

Finds 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.

property url

The URL to the article’s display page.

Type

str

Utility Functions

tibiawikisql.utils.clean_question_mark(content)[source]

Removes 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

Removes 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]

Converts 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.parse_boolean(value: str, default=False, invert=False)[source]

Parses 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_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]

Parses 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]

Gets every dropped item from a creature’s loot statistics. :param value: A string containing a creature’s loot statistics. :type value: str

Returns

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

Return type

tuple

tibiawikisql.utils.parse_min_max(value)[source]

Parses 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]

Parses 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]

Converts 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