CorgiDB.utils.create_table

CorgiDB.utils.create_table(name: str, columns: list)

this method will create_table on the connected database

Parameters

  1. name : str

    name of the table, e.g., "Personnel", "Student"

  2. columns : list

    columns contain in the table in form of ("Columns name", dtype) in list

    e.g., [("name", str), ("age", int)] with only int, float, bool, str are supported

Returns

  1. out : Table

    CorgiDB's Table object for us to manipulate the table after the creation

class Table

Notes

Creating an already existing Table will raise an SQLite3 error

Examples

from corgidb import CorgiDB

# Connect CorgiDB to db.sqlite
cdb = CorgiDB(database_path="db.sqlite")

# Create a Table
tb = cdb.utils.create_table(
    name="Employee"
    columns=[
        ("name"     , str),
        ("gender"   , str),
        ("age"      , int),
        ("height"   , float),
        ("weight"   , float)
])

Last updated