Skip to main content

A simple database system

Project description

#sunlite

Sunlite Simple Database System

[*Jump to sunlite database server]

simple, fast, local, userfriendly

Speed Menu

for sunlite database

[*Jump to sunlite database connection]
[*Jump to sunlite database tutorials]
[*Jump to sunlite database examples]

for sunlite server database

[*Jump to sunlite database server Q/A]
[*Jump to sunlite database server getting started]
[*Jump to sunlite database server how to links]

what is sunlite ?

Ans: Sunlite is a module for simple data management.

  • How to use
    • Connect to memory.
    • connect to a database.
    • Create a new header . >> * add data , or pull data
      • enjoy ^~^

Connecting

Sunlite lets you connect as you want.

from sunlite.db import connect

db = connect() #for memory
db = connect("my_db") #for connecting with "my_db" , it will be auto generated if doesnt exists.
db = connect("my_db",logs=False)  # for connecting to "my_db" but say no to logs

Generating new header

headers are like boxes which contains your datas , don't forget to make one before pushing or pulling data

db = connect("my_db")

db.new("websites")  #here , we made a header named websites.

Pushing data to headers

by pushing , we add data in headers to contain . you can push any data .

db = connect("my_db")

db.new("websites")

name = "google"
data = "http://google.com"

db.push(name,data) #here , we are pushing http://google.com with the name google in websites header

Pullling data from headers

you can pull all data of header or an invidual data

db = connect("my_db",logs=False)

db.new("websites")

name = "google"
data = "http://google.com"

db.push(name,data)

a = db.pull("websites")  #it will pull all data in website header as a dictionary.

a = db.pull("google")  #it will only pull the data of google no matter where it is in which header .

don't use same names for two datas as it will remove 2nd one .

Get a header as you want. This time duplicate names are accepted.

unlike pull function , this function doesn't update duplicate datas as sends as they are .

this is useful in maintaining a large set of same data.

example

db.connect("students",logs=False)

db.new("Allan")

db.push("maths",50)
db.push("english",70)
db.push("science",40)


#now for akmal
db.new("Akmal")

db.push("maths",45)
db.push("english",60)
db.push("science",70)

db.get("Akmal")  #for getting akmal marks
db.get("allan") #for getting allan's marks

Beauty print .

You can beauty print all data's in all headers .

db = connect("my_db",logs=False)

db.new("websites")

name = "google"
data = "http://google.com"

db.push(name,data)

db.beauty()  #this prints all data nicely

Get all headers

db = connect("my_db",logs=False)

db.headers()

Example with a user info system with sunlite

db = connect("my_db",logs=False)

db.new("users")

name = "Axel"
data = ["age":13 , "nation": "USA"]

db.push(name,data)

name = "Jack"
data = ["age":15, "nation": "England"]
db.push(name,data)

db.beauty()

Sunlite Server

Sunlite server is a database server which can be generated in memory or in a physical database .

Why and How ?

Q. Why Sunlite need database server ? A. Sunlite is a python system which can't be used from other languages but with sunlite server, users can use this simple database system from any programming language after invoking the server with python. Q. How to use sunlite server from different programming languages? A. Using http get requests to server. Wrappers from different languages coming soon.

I think i am ready for my first server :)

To start a server of your existing sunlite database ( tutorials above about using sunlite database system ) , simply login to your python console installed and execute from sunlite.server import Serve

from sunlite.server import Serve
Serve(name="[DBNAME]" , logfolder="[LOGPATH]").invoke()
# [DBNAME] is the database name you created using sunlite or any name if you want to create a new. remember sunlite can connect to database #  you create with server and vice versa.
# [LOGPATH] is the path to log your server tasks. ex. 'E:/logs'

So to connect a sunlite database with the name 'test' and save it's logs in a folder named logs in the project directory , just do

from sunlite.server import Serve
Serve(name="test" , logfolder="logs").invoke()

and your server will start running in http://localhost:5000

to disable or unable logs , you can use logs=True or logs=False inside Serve.

Ex. for turning logs off

from sunlite.server import Serve
Serve(name="test" , logs=False , logfolder="logs").invoke()

logs are on by default.

To open the server on your prefered ip address,
from sunlite.server import Serve
Serve(name="test" , logs=False , logfolder="logs").invoke(ip='your ip' , port = your_port)
#example Serve(name="test" , logs=False , logfolder="logs").invoke(ip='127.0.0.1' , port = 5000)

Links to send database requests.

to get all data in your database

http://[your-ip]:[your-port]/a/

to get header list

http://[your-ip]:[your-port]/h/

to create a new header

http://[your-ip]:[your-port]/new/[header-name]

to pull a data

http://[your-ip]:[your-port]/p/[data-name]

to get total data of a header

http://[your-ip]:[your-port]/g/[header-name]

to add a data or modify in a header

http://[your-ip]:[your-port]/add/[data-name]/[data]/[header-name]

do remember html link syntaxes.

ex.

http://127.0.0.1:5000/p/hello will pull the data named hello http://127.0.0.1:5000/g/myheader will pull data from the header myheader etc

Important

format spaces with %20f

ex. if your data name was my data make the link like http://127.0.0.1:5000/p/my%f20data not http://127.0.0.1:5000/p/my data

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

sunlite-1.0.7.tar.gz (91.5 kB view hashes)

Uploaded Source

Supported by

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