Skip to main content

pybraads Readme 📜

Brainstorming package, manage ODBC connexion to database Advantage Database.

Installation ⚡

Opérating system : Windows, MacOS & Linux :

Available function/class 📑

AdsConnection(DataDirectory, Uid, Pwd, MoreParam, ServerType)

To create ans open data base
DataDirectory : a full path to the data dictionary with ".add" file.
Uid  : the data base user.
Pwd : The data base password
MoreParam : def value None, added parameter for connection string without ';' at the end.
ServerType : def value 'REMOTE', server type for ADS connection.
             Valid values: 'REMOTE', 'LOCAL', 'INTERNET'
The default connection string contains the parameters:
"TrimTrailingSpaces=TRUE;ServerType=REMOTE;Locking=Opportunistic;"

Close()

To close data base

commit()

To save all modification in data base

rollback()

To cancel all modification in data base after the last commit

isconnected

To test if the data base is connected

error

To get the last error

AdsQuery(adsconn)

To create à new query.
adsconn : is the AdsConnection of the data base tu use.

sql

To get or set the query before open.
the parameters in query must be prefixed by ":" like :prefref.

addparam(aParamName, aParamValue)

aParamName : the name of the parameter in the query (without the :) attention case sesitive.
aParamValue : any value for the parameter.

execute()

Execute the query.

open()

Open the query.

error

The get the last execution error

fieldnames

To get a list of all field in the select

FieldIndex(afieldname)

To get the field position in the query, to use with the dataset.

eof

To navigate in all the database unti last record

allrecords

To get a list with all record in database

dataset

To get one record to read the specific field like :
Query.dataset[aQuery.FieldIndex('FirstName')]

Howto use 📰

import pybraads
import pybrastr

try:
    DataDirectory = "\\\\192.168.91.1\\d\\DevBrain\\Python\\pybraads\\dbtest\\dbtest.add"
    user = "adssys"
    password = "123"
    aConn = pybraads.AdsConnection(DataDirectory, user, password)
    aQuery = pybraads.AdsQuery(aConn)

    #Chesk if table exist
    sql = ''.join(["select * from system.tables ",
                   "where Name = ", pybrastr.quotedStr("DEMO1")
                   ])
    aQuery.sql = sql
    aQuery.open()
    tblfound = aQuery.dataset[aQuery.FieldIndex('Name')] != "DEMO1"

    if tblfound:
        #Delete existing table
        print("Table DEMO1 not exist")            
        return False
    
    sql = ''.join(["select * from DEMO1 "])
    aQuery.sql = sql
    aQuery.open()

    fields = ''
    for field in aQuery.fieldnames:
        if fields == '':
            fields = fields + field.ljust(20, ' ')
        else:
            fields = fields + ' | ' + field.ljust(20, ' ')
    
    print(fields)
    print(''.center(len(fields), '-'))

    while not(aQuery.eof):
        ln = ''
        ln = aQuery.dataset[aQuery.FieldIndex('FirstName')].ljust(20, ' ')
        ln = ln + ' | ' + aQuery.dataset[aQuery.FieldIndex('Name')].ljust(20, ' ')
        ln = ln + ' | ' + aQuery.dataset[aQuery.FieldIndex('BirthDate')].strftime('%Y-%m-%d').ljust(20, ' ')
        print(ln)
    
finally:
    aConn.Close()
    print(pybraads.version())

Meta 💬

Brainstorming – Support.erp@brainstorming.eu

Distributed under the MIT license. See LICENSE for more information.

Release files for pybraads 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybraads 0.1.7
File Size Uploaded
pybraads-0.1.7.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pybraads 0.1.7
File Interpreter ABI Platform
pybraads-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / pybraads-0.1.7.tar.gz

Download URL pybraads-0.1.7.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
56782f2cf1fbee19a39146596b18e8f2212e76b2143af48646ef75068d42813f
BLAKE2b-256 checksum
How to use checksums
a1f6cbd2a09aeb9968f2a35382ee75af13793c8842bd3939a1ed7a50c6b3e26b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.13.1 Windows/11

Release files / pybraads-0.1.7-py3-none-any.whl

Download URL pybraads-0.1.7-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa9868ea409b0aaed8f31c7f960ef226bc56387b71ba850776cecad711383b5a
BLAKE2b-256 checksum
How to use checksums
4183ebba4483acbaf7eb7f0bf2a871e2daa4a560ee6d81ffc2a9c04338561739
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.13.1 Windows/11

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page