codebase for python basic documentation
Python for Windows Basic documentation:
Installation
It is possible to get Codebase for Python up and running on Windows
even when you do not have a C compiler installed.
- It is assumed that you already have Python2.1 installed in c:\python21
and that it is working correctly
- Download codebase from
https://www.codebase.com/downloads/windows/cb65.exe You need to purchase
codebase to gain access to this window and it can be purchased from
https://www.codebase.com/order/
- Install Codebase6 into
the directory c:\codebase. I chose the options to include the
the MSV 1.6 support but do not actually have MSVC installed. I installed
my version in C:\codebase I have my Python in installed in c:\python21
- Once codebase6 is installed copy: c:\codbase\DLL32\C4FOX.DLL
to c:\python21\C4DLL.DLL
NOTE: You can actually delete c:\codebase once you
have copied the C4DD.DLL but you will probably need to look at their samples
so it is not recommended.
- Download
http://www.dynaset.org/dogusanh/download/Py21CodeBase.zip and unzip
the files. Once unzipped copy CodeBase.py and CodeBasec.pyd
to c:\python2
- Make sure that
PYTHONPATH includes c:\python21
PATH includes c:\python2
- Examples showing how to use Python with Codebase are located
at http://www.dynaset.org/dogusanh/download/PyExCodeBase.zip
download this directory and unzip it. I put this in c:\codebase\python\examples
Copy the following sample files from codebase
to the same directory where you unziped the python examples:
copy c:\codebase\cpp\examples\*.dbf c:\codebase\python\examples
copy c:\codebase\cpp\examples\*.cdx c:\codebase\python\examples
copy c:\codebase\cpp\examples\*.fpt c:\codebase\python\examples
- Confirm correct operation by running the following
tests. If these succeed then Codebase is working correctly.
- python ex8.py - Creates a table with a couple
fields. After this file runs there should be a new file named NO_FILE.DBF
Getting Started (Tutorial)
for Codebase Python
- bank.py - create a table with
multiple indexes., Add some data and walk the data to print out.
- cppeg.py - create a database
table and a index on that table.
- newlist.py - Create two new database
tables. Add many fields to tables, Adds a some
records to the files, walks the,
- newlist2.py - Create two new database
tables. Add many fields to tables, Adds a bunch of single
segment keys, Adds a files and prints out the contents mutli segment
key, Adds a bunch of records to the files, walks the, files and
prints out the contents.
- EX8.py - creates small table with
two columns only if the table does not already exist.
- EX14.py - Open a table and search
for a specific value in a column. (Failed with Error)
- EX1.py - Creates a new database with
three column
-
Add a Index on columns in a Table
- bank.py - create a table with
multiple indexes., Add some data and walk the data to print out.
- cppeg.py - create a database
table and a index on that table.
- newlist2.py
- ex95.py - manually building
segmented key
-
Adding
Data to a Table
- bank.py - create a table with
multiple indexes., Add some data and walk the data to print out.
- newlist.py - Create two new database
tables. Add many fields to tables, Adds a some
records to the files, walks the,
- newlist2.py - Create two new
database tables. Add many fields to tables, Adds a bunch
of single segment keys, Adds a files and prints out the contents mutli
segment key, Adds a bunch of records to the files, walks the,
files and prints out the contents.
- append.py - adding data to database
with optimized write lock.
- ex30.py - copy an existing record
as template for new appended record
- ex34.py - simple add a new
record and set it's field contents. Demonstrates access value of string
field by name.
- ex31.py - Add 5 blank records
-
Search for a Record with a specific Indexed value:
- ex65.py - indexed search
for a data also get first alpha value from a index
- ex63.py - search on specifc
values and on compound keys. Includes search by date and by numeric
-
Search Index for All Values Beginning
- ex69.py - find the first record
in the index with a specified value and then find all records which also
have that value.
-
Retrieve all records matching a search criteria
- ex64.py - Search
for specific value and return set of records with that value
- ex66.py - find the last
record not equal to a value - linear search
- ex69.py - find the first record
in the index with a specified value and then find all records which also
have that value.
- Numeric
- ex8.py - define numeric column
- String
- ex8.py - define a string column
- Date Column
- date1.py - date calculation demonstration
- ex76.py - demonstrates date
calcuations
- ex75.py - demonstrate
searching by date
- ex74.py - Indexed
searching by date
- ex79.py - formated
data converstion and calculation
- ex77.py - Special Equality
/ Boolean operators on date objects
- Variable Length String
- Memo
-
Modifying a Value in a Existing Database Field
- ex27.py - Modify the value of
a field for every record
-
Deleting a Database Record
- deletion.py - demonstrate removing
records from a file and cleaning up when done.
- ex24.py - print out a list
of records marked for deletion
- ex39.py - delete two records
and reclaim space
-
Accessing
Meta Data
- datainfo.py - Fetch and display meta
data about a file
- ex28.py - Get number of records in
file
- ex24.py - print out a list
of records marked for deletion
- ex38.py - get count of deleted
records
- ex36.py - validate an
index is consistent with it's database
- ex35.py - determine if
record has been changed in current buffer.
- ex99.py - dump all the
fields for all the rcords of a file to the screen.
-
Locking
& Transcations
- ex26.py - Demonstrate Exclusive
Lock & Unlock for file
- ex25.py - Locking with Optimize
Write
- ex23.py - Demonstrate locking
individual records
-
Relations
& Search
- relate.py, relate1.py, relate3.py,
- demonstrate related record lookup.
- relate2.py - demonstrate sort functionaly
in conjustion with relation
-
Building Index / Tag files without an associated Database
-
Tools &
Utilities
- copydata.py - copy one database to
another file
- copydata.py - copy one database including
indexes to another file.
- ex37.py - create a new database
erasing the current one if it exists. Demonstrates copying structure
of one table to another.
- ex36.py - validate an
index is consistent with it's database
- ex62.py - Rebuild index
files
- ex71.py - kill the last
N records in a file
Index of
Example Code
- append.py - adding data to database
with optimized write lock.
- bank.py - create a table with
multiple indexes., Add some data and walk the data to print out.
- cppeg.py - create a database table
and a index on that table.
- copydata.py - copy one database to another
file
- copydata.py - copy one database including
indexes to another file
- custbase.py - .. - didn't work
- datainfo.py - Fetch and display meta
data about a file
- date1.py - date calculation demonstration
- deletion.py - demonstrate removing records
from a file and cleaning up when done.
- multi.py - add, search, modify, records
but doesn't seem to work.
- newlist.py - Create two new database
tables. Add many fields to tables, Adds a some
records to the files, walks the, newlist2.py - Create two new
database tables. Add many fields to tables, Adds a bunch
of single segment keys, Adds a files and prints out the contents mutli
segment key, Adds a bunch of records to the files, walks the,
files and prints out the contents.
- relate.py, relate1.py, relate3.py,
- demonstrate related record lookup.
- relate2.py - demonstrate sort functionaly
in conjustion with relation
- transfer.py - no work
- EX0.py - Initialize the codebase sub
system.
- EX1.py - Creates a new database with
three columns
- EX2.py - Manually open an index
file to go with a database
- EX4.py - Blocking append of dupliate
record
- EX6.py - ..
- EX7.py - seeking to end of file.
- EX8.py - creates small table with two
columns only if the table does not already exist.
- EX9.py -
- EX10.py - Locking Stuff
- EX11.py - Loop Across a Set of Records
Looking at the data value of a field. Shows conversion of the Codebase
field value to a python internal data type
- EX12.py - Demonstrate Expressions following
Dabase Syntax
- EX13.PY - Detect a locked record and
retry access.
- EX14.py - Open a table and search for
a specific value in a column. (Failed with Error)
- EX15.py - Create a Database Table and
Add fields to this table.
- ex16.py - Copy an entire record
buffer from the database (space padded)
- EX18.py - Get number of records in a
file.
- EX19.py - Get number of records in a
file
- ex20.py - display console message
- ex21.py - application abort
- ex22.py - aplication abort
on missing file
- ex23.py - Demonstrate locking
individual records
- ex24.py - print out a list of
records marked for deletion
- ex25.py - Locking with Optimize
Write
- ex26.py - Demonstrate Exclusive
Lock & Unlock for file
- ex27.py - Modify the value of
a field for every record
- ex28.py - Get number of records in file
- ex29.py - .. - failed
- ex30.py - copy an existing record
as template for new appended record
- ex31.py - Add 5 blank records
- ex32.py - Blank out all records
in the database
- ex33.py - walk an entire
file in reverse order.
- ex34.py - simple add a new record
and set it's field contents. Demonstrates access value of string field
by name.
- ex35.py - determine if
record has been changed in current buffer.
- ex36.py - validate an index
is consistent with it's database
- ex37.py - create a new database
erasing the current one if it exists. Demonstrates copying structure
of one table to another.
- ex38.py - get count of deleted
records
- ex39.py - delete two records
and reclaim space
- ex40.py - jump to end of file
- ex60.py - Re-read (refresh)
record from disk. This may be necessary if somebody else has
changed it.
- ex61.py - modify first
record in file.
- ex62.py - Rebuild index
files
- ex63.py - search
on specifc values and on compound keys. Includes search by date and
by numeric
- ex64.py - Search for specific
value and return set of records with that value
- ex65.py - indexed search
for a data also get first alpha value from a index
- ex66.py - find the last
record not equal to a value - linear search
- ex68.py - walk an entire
file in sorted sequence by selected index
- ex69.py - find the first record
in the index with a specified value and then find all records which also
have that value.
- ex70.py - overlay all records
in the file with the contents of the first record.
- ex71.py - kill the last
N records in a file
- ex74.py - Indexed
searching by date
- ex75.py - demonstrate searching
by date
- ex76.py - demonstrates date calcuations
- ex77.py - Special Equality /
Boolean operators on date objects
- ex78.py - formated date calculations
- ex79.py - formated data
converstion and calculation
- ex92.py - Using an
expression to build new strings for each recrd in current buffer (very cool)
- ex95.py - manually building segmented
key
- ex99.py - dump all the
fields for all the rcords of a file to the screen.
Written by Joseph Ellsworth of Coherity,
Inc July-2002 joe@coherity.com