Skip to main content

This repository contains all the libraries for successful working with Surfy Ecosystem in a Python environment.

Project description

Surfy Core Ecosystem for Python

This repository contains all the libraries for successful working with Surfy Ecosystem in a Python environment.

Surfy

Installation

pip3 install surfy

Libraries


SQLite

Usage

from surfy.sqlite import SQLite
db = SQLite('PATH_TO_FILE')

Query

result = db.query('''CREATE TABLE IF NOT EXISTS test_table
	(id INTEGER PRIMARY KEY AUTOINCREMENT,
	createTime TEXT COLLATE NOCASE,
	data TEXT COLLATE NOCASE,
	extradata TEXT,
	counter INTEGER,
	realNumber REAL,
	object TEXT,
	array TEXT);''')

.remove()

db.remove()

.table(table_name)

table = db.table('test_table')

table.insert_one(row)

row = {
	'createTime': 'CURRENT_TIME',
	'data': 'Some Data 1',
	'extradata': 'Some Extra Data',
	'counter': 2,
	'realNumber': 2.52,
	'object': {
		'field': 'value'
	},
	'array': [1,2,3]
}

inserted_id = table.insert_one(row) # Integer

table.insert(rows)

rows = [
	{
		'createTime': 'CURRENT_TIME', 'data': 'Some Data 1'
	},
	{
		'createTime': 'CURRENT_TIME', 'data': 'Some Data 2'
	},
	{
		'createTime': 'CURRENT_TIME', 'data': 'Some Data 3'
	}
]

inserted_ids = table.insert(rows) # List of Integers

table.find_one(match, options)

match = {
	'data': 'Some Data 2'
}

options = {
	'fields': ['id', 'currentTime', 'data']
}

result = testTable.find_one(match, options)

'''

result {
	'id': 3,
	'currentTime': datetime.datetime(2023, 2, 10, 21, 2, 20),
	'data': 'Some Data 2'
}

'''

table.find(match, options)

match = {
	'data': {
		'$like': 'Some Data %'
	}
}

options = {
	'fields': ['id', 'currentTime', 'data'],
	'skip': 2,
	'limit': 1
}

result = testTable.find(match, options)

'''

result [
	{
		'id': 3,
		'currentTime': datetime.datetime(2023, 2, 10, 21, 2, 20),
		'data': 'Some Data 2'
	}
]

'''

table.update_one(match, update, options)

Updates first matched record

match = {
	'data': {
		'$like': 'Some Data %'
	}
}

update = {
	'currentTime': 'CURRENT_TIME'
}

options = {
	'skip': 2,
	'limit': 1
}

result = testTable.update_one(match, update, options)

table.update(match, update, options)

Updates all matched records

match = {
	'data': {
		'$like': 'Some Data %'
	}
}

update = {
	'currentTime': 'CURRENT_TIME'
}

options = {
	'skip': 2
}

result = testTable.update(match, update, options)


MIT License

Alexander Yermolenko • surfy.one

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

surfy-1.0.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

surfy-1.0.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file surfy-1.0.3.tar.gz.

File metadata

  • Download URL: surfy-1.0.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.6

File hashes

Hashes for surfy-1.0.3.tar.gz
Algorithm Hash digest
SHA256 41f7b35d3c284b71086c98b8186c0f358ff8bd740f1061c81c1b649d0e5de72f
MD5 5ac1d7a7dbb9419da4bd1dde845392d3
BLAKE2b-256 31320ae9565f2fe021aa0adb3d7c888d55764b9a4a2f43baaec6d13ac7e73afa

See more details on using hashes here.

File details

Details for the file surfy-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: surfy-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.6

File hashes

Hashes for surfy-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4506328f7b5dc3c0459d52c892ffd11eccb7bac96cb945a91691eb6d0def05d7
MD5 bb2f1c47b522cc38385ed7ede020cd88
BLAKE2b-256 34a145fcd394e48b6aaaeecdc3915494430b92f5c7def1319faf4bc3d56ec43e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page