Skip to main content

Brainstorming package, manage ODBC connexion to database Advantage Database.

Project description

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)

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.
The default connection string containt the paramerters 
"TrimTrailingSpaces=TRUE;ServerType=REMOTE;"

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybraads-0.1.6.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybraads-0.1.6-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file pybraads-0.1.6.tar.gz.

File metadata

  • Download URL: pybraads-0.1.6.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.11 Windows/10

File hashes

Hashes for pybraads-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b5757e59e8fb0c9780d9c3af54b03578d62ef9123cf52218623fb8cc6f1bf4a3
MD5 82b3dd2adae549a1c41b77133ef3df97
BLAKE2b-256 c313496d3e8461536a234e4c7337432436673a6b392c996b8dd4e64306dd6701

See more details on using hashes here.

File details

Details for the file pybraads-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: pybraads-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.11 Windows/10

File hashes

Hashes for pybraads-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 48ab65bc1a75b4d24bb5a873040f095a1cee292547ffee79db1636c31b023c29
MD5 7093fcb21b7cf9a6185fc07a12553a3f
BLAKE2b-256 7e56ab57ef1e05652da97770a3d6a647e7241296636a223fd297427d51418d5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page