Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 1.59 KB

db_loading.md

File metadata and controls

50 lines (37 loc) · 1.59 KB
title description date author tags
Load an existing database
How to load an existing database into a Python process
July 2024
KX Systems, Inc.,
PyKX, q, database, loading

Load an existing database

This page explains how to load an existing database into a Python process.

!!! tip "Tip: For the best experience, we recommend reading Databases in PyKX and generate a database first."

By default, you can only load one database into a Python process when using PyKX. To automatically load a database when initializing the #!python pykx.DB class, set the database location as the path:

>>> import pykx as kx
>>> db = kx.DB(path='/tmp/db')
>>> db.tables
['quote', 'trade']

To load a database after initialization, use the #!python load command as shown below:

>>> import pykx as kx
>>> db = kx.DB()
>>> db.tables
>>> db.load('/tmp/db')
>>> db.tables
['quote', 'trade']

Change the loaded database

To overwrite the database loaded and use another database if needed, use the #!python overwrite keyword.

In the below example, we are loading a new database #!python /tmp/newdb which in our case doesn't exist but mimics the act of loading a separate database:

>>> db = kx.DB(path='/tmp/db')
>>> db.load(path='/tmp/newdb', overwrite=True)

Next Steps