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.
-
classmethod
get_category_members_titles
(name, skip_index=True)[source]¶ Generator that obtains a list of article titles in a 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.
-
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.
-
classmethod
WikiEntry¶
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
¶ database.Table
– The SQL table where this model is stored.
-
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 useLIKE
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 useLIKE
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
Models¶
Achievement¶
-
class
tibiawikisql.models.
Achievement
[source]¶ Represents an Achievement.
-
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 useLIKE
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 useLIKE
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.
-
classmethod
Creature¶
-
class
tibiawikisql.models.
Creature
[source]¶ Represents a creature.
-
loot
¶ list of
CreatureDrop
– The items dropped by this creature.
-
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
-
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 useLIKE
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 useLIKE
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.
-
CreatureDrop¶
-
class
tibiawikisql.models.
CreatureDrop
[source]¶ Represents an item dropped by a creature.
-
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 useLIKE
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 useLIKE
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.
-
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 useLIKE
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 useLIKE
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.
-
classmethod
Imbuement¶
-
class
tibiawikisql.models.
Imbuement
[source]¶ Represents an imbuement type.
-
materials
¶ list of
ImbuementMaterial
– The materials needed for the imbuement.
-
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 useLIKE
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 useLIKE
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.
-
ImbuementMaterial¶
-
class
tibiawikisql.models.
ImbuementMaterial
[source]¶ Representes a item material for an imbuement.
-
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 useLIKE
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 useLIKE
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.
-
attributes
¶ list of
ItemAttribute
– The item’s attributes.
-
dropped_by
¶ list of
CreatureDrop
– List of creatures that drop this item, with the chances.
-
sold_by
¶ list of
NpcSellOffer
– List of NPCs that sell this item.
-
bought_by
¶ list of
NpcBuyOffer
– List of NPCs that buy this item.
-
awarded_in
¶ list of
QuestReward
– List of quests that give this item as reward.
-
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 useLIKE
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 useLIKE
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.
-
ItemAttribute¶
-
class
tibiawikisql.models.
ItemAttribute
[source]¶ Represents an Item’s attribute
-
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 useLIKE
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 useLIKE
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.
-
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 useLIKE
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 useLIKE
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.
-
Npc¶
-
class
tibiawikisql.models.
Npc
[source]¶ Represents a non-playable character.
-
sell_offers
¶ list of
NpcSellOffer
– Items sold by the NPC.
-
buy_offers
¶ list of
NpcBuyOffer
– Items bought by the NPC.
-
destinations
¶ list of
NpcSellOffer
– Places where the NPC can travel to.
-
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 useLIKE
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 useLIKE
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.
-
NpcDestination¶
-
class
tibiawikisql.models.
NpcDestination
[source]¶ Represents a NPC’s travel destination
-
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 useLIKE
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 useLIKE
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.
-
classmethod
NpcBuyOffer¶
-
class
tibiawikisql.models.
NpcBuyOffer
[source]¶ Represents an item buyable by an NPC.
-
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 useLIKE
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 useLIKE
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.
-
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 useLIKE
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 useLIKE
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.
-
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 useLIKE
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 useLIKE
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
-
dangers
¶ list of
QuestDanger
– Creatures found in the quest.
-
rewards
¶ list of
QuestReward
– Items rewarded in the quest.
-
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 useLIKE
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 useLIKE
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.
-
QuestDanger¶
-
class
tibiawikisql.models.
QuestDanger
[source]¶ Represents a creature found in the quest.
-
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 useLIKE
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 useLIKE
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.
-
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 useLIKE
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 useLIKE
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.
-
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 useLIKE
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 useLIKE
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.
-
classmethod
Spell¶
-
class
tibiawikisql.models.
Spell
[source]¶ Represents a Spell
bool
– Whether the spell is premium only or not.
-
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 useLIKE
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 useLIKE
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.
Utility Functions¶
-
tibiawikisql.utils.
clean_links
(content)[source]¶ Removes any links from the string, changing them for their plan version.
-
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.
-
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
- Returns
The boolean value parsed in the string, or default if it doesn’t match yes or no.
- Return type
-
tibiawikisql.utils.
parse_float
(value, default=0)[source]¶ From a string, parses a floating value. :param value: The string containing the floating number. :type value:
str
:param default: The value to return if no float is found. :type default:float
, optional- Returns
The floating number found, or the default value provided.
- Return type
-
tibiawikisql.utils.
parse_integer
(value, default=0)[source]¶ Parses an integer from a string. Extra characters are ignored.