Login
Back to bricks list
Introduction Version

Sqlite resource

RESOURCE
Typing name :  RESOURCE.gws_core.SqliteResource Brick :  gws_core
Parent :
File

Resource that represents a file in the system.

Technical notes:

/!\ The class that extend file can only have a path and file_store_id attributes. Other attributes will not be provided when creating the resource.

Views

VIEW CONTENTDefault view
Show content of the database
EXECUTE QUERY
Show the result of a select query
TABLE NAMES
List the tables of the database
VIEW TABLE
Show the content of a table

Attributes

file_store_id: stris_symbolic_link: boolname: strpath: strstyle: TypingStyletags: TagListtechnical_info: TechnicalInfoDictuid: str

Functions

__INIT__

Create a new FSNode

Parameters:
NameTypeDefault valueDescription
pathstr '' Absolute path to the file, defaults to "" , optional
ADD_TECHNICAL_INFO

Add technical information on the resource. Technical info are useful to set additional information on the resource.

Parameters:
NameTypeDefault valueDescription
technical_infoTechnicalInfo Technical information to add (key, value)
CHECK_RESOURCE

You can redefine this method to define custom logic to check this resource. If there is a problem with the resource, return a string that define the error, otherwise return None This method is called on output resources of a task. If there is an error returned, the task will be set to error and next proceses will not be run. It is also call when uploading a resource (usually for files or folder), if there is an error returned, the resource will not be uploaded

Return type:
Optional
CLONE

Clone the resource to create a new instance with a new id. It copies the RFields.

Return type:
ResourceType
COPY_TO_DIRECTORY

Copy the node to the directory and keep the same base name

Parameters:
NameTypeDefault valueDescription
destinationstr The destination directory
Return type:
str
COPY_TO_PATH

Copy the file to the target path

Parameters:
NameTypeDefault valueDescription
destinationstr
Return type:
str
DETECT_FILE_ENCODING

Detect the encoding of the file using charset-normalizer

Parameters:
NameTypeDefault valueDescription
default_encodingstr utf-8 Default encoding to use if the encoding is not detected, defaults to 'utf-8' , optional
Return type:
str
EXECUTE_SELECT
Parameters:
NameTypeDefault valueDescription
querystr
Return type:
Table
EXISTS
GET_BASE_NAME

Get file name with extension

Return type:
str
GET_DEFAULT_NAME

You can redefine this method to set a name of the resource. When saving the resource the name will be saved automatically This can be useful to distinguish this resource from another one or to search for the resource

Return type:
str
GET_DEFAULT_VIEW

Get the default view of the file.

Parameters:
NameTypeDefault valueDescription
pageint 1 Page number, defaults to 1 , optional
Return type:
View
GET_SIZE
Return type:
int
GET_TABLE_NAMES
Return type:
List
GET_TECHNICAL_INFO

Get the technical information of the resource

Parameters:
NameTypeDefault valueDescription
keystr Key of the technical information
Return type:
TechnicalInfo
GET_VIEW_BY_LINES
Parameters:
NameTypeDefault valueDescription
start_lineint 1
Return type:
SimpleTextView
INIT

This can be overwritten to perform custom initialization of the resource. This method is called after the init (constructor) of the resource. The values of RFields are set when this method is called.

IS_CSV
IS_EMPTY
Return type:
bool
IS_IMAGE
IS_JPG
IS_JSON
IS_PNG
IS_READABLE
Return type:
bool
IS_TXT
OPEN

Open the file

Parameters:
NameTypeDefault valueDescription
modestr Mode of the file
encodingstr Encoding used to open the file. if none the encoding is automatically detected with charset-normalizer, defaults to none , optional
Return type:
Any
READ

Read the file

Parameters:
NameTypeDefault valueDescription
sizeint -1 Size of the file to read, defaults to -1 , optional
encodingstr Encoding used to read the file. if none the encoding is automatically detected with charset-normalizer, defaults to none , optional
modestr r+t Mode of the file, defaults to 'r+t' , optional
Return type:
AnyStr
READ_PART

Read a part of the file

Parameters:
NameTypeDefault valueDescription
from_lineint 0 Start line, defaults to 0 , optional
to_lineint 10 End line (excluded), defaults to 10 , optional
encodingstr Encoding used to read the file. if none the encoding is automatically detected with charset-normalizer, defaults to none , optional
modestr r+t Mode of the file, defaults to 'r+t' , optional
Return type:
str
SELECT_TABLE
Parameters:
NameTypeDefault valueDescription
table_namestr
Return type:
Table
VIEW_AS_JSON

By default the view_as_json dumps the RFields mark with, include_in_dict_view=True This method is used to send the resource information back to the interface

Parameters:
NameTypeDefault valueDescription
paramsConfigParams
Return type:
View
VIEW_CONTENT_AS_STR
Parameters:
NameTypeDefault valueDescription
paramsConfigParams
Return type:
View
WRITE

Write data to the file

Parameters:
NameTypeDefault valueDescription
datastr Data to write
encodingstr Encoding used to write the file. if none the encoding is automatically detected with charset-normalizer, defaults to none , optional
modestr a+t Mode of the file, defaults to 'a+t' , optional
CLASSNAME - @classmethod

Returns the name of the class

Parameters:
NameTypeDefault valueDescription
slugifybool False True to slugify the class name if true, defaults to false , optional
snakefybool False True to snakefy the class name if true, defaults to false , optional
replace_uppercasebool False Replace upper cases by "-" if true, defaults to false , optional
Return type:
str
COPY_STYLE - @classmethod

Copy the style of the resource with the possibility to override some properties. Useful when settings the style for a task based on the resource style.

Parameters:
NameTypeDefault valueDescription
icon_technical_namestr Technical name of the icon if provided, the icon_type must also be provided, defaults to none , optional
icon_typeTypingIconType Type of the icon if provided, the icon_technical_name must also be provided, defaults to none , optional
background_colorstr Background color, defaults to none , optional
icon_colorTypingIconColor Icon color, defaults to none , optional
Return type:
TypingStyle
DECORATED_METHOD_NAMES - @classmethod
Parameters:
NameTypeDefault valueDescription
decorator_nameAny
FULL_CLASSNAME - @classmethod

Returns the full name of the class

Parameters:
NameTypeDefault valueDescription
slugifybool False Slugify the returned class name if true, defaults to false , optional
snakefybool False Snakefy the returned class name if true, defaults to false ``
Return type:
str
INHERITORS - @classmethod

Get all the classes that inherit this class

Return type:
List
METHOD_NAMES - @classmethod

Returns the list of the methods

Return type:
List
MODULE_NAME - @classmethod

Returns the module name of the class

Return type:
str
PROPERTY_METHOD_NAMES - @classmethod
PROPERTY_NAMES - @classmethod

Retrieves the property names

Parameters:
NameTypeDefault valueDescription
instancetype The s of the properties to retrieve. set `none` to retrieve all. `type` or `union[type]`
excludetype
Return type:
List