CorgiDB Docs
  • CorgiDB
  • Installation
  • Quickstart
  • class CorgiDB
    • CorgiDB.utils.create_table
    • CorgiDB.utils.get_table
    • CorgiDB.utils.delete_table
  • objects Package
    • class Table
      • corgidb.objects.Table.cols
      • corgidb.objects.Table.delete
      • corgidb.objects.Table.get
      • corgidb.objects.Table.insert
      • corgidb.objects.Table.update
      • corgidb.objects.Table.remove
    • class Condition
    • class DataChunk
Powered by GitBook
On this page
  1. class CorgiDB

CorgiDB.utils.create_table

Previousclass CorgiDBNextCorgiDB.utils.get_table

Last updated 2 years ago

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

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)
])

class Table