-

ska_dbi

+

ska_dbi

ska_dbi provides simple methods for database access and data insertion. Features:

    -
  • Sqlite and sybase connections are supported.

  • -
  • Automatic fetching of Ska database account passwords.

  • +
  • Sqlite connections are supported.

  • Integration with numpy record arrays.

  • Verbose mode to show transaction information.

  • -
  • Insert method smooths over syntax differences between sqlite and sybase.

-

Functions

+

Functions

ska_dbi.DBI._denumpy(x)[source]
@@ -83,33 +80,29 @@

Functions -

Classes

+

Classes

-class ska_dbi.DBI.DBI(dbi=None, server=None, user=None, passwd=None, database=None, numpy=True, autocommit=True, verbose=False, authdir='/proj/sot/ska/data/aspect_authorization', **kwargs)[source]
+class ska_dbi.DBI.DBI(dbi=None, server=None, numpy=True, autocommit=True, verbose=False, **kwargs)[source]

Bases: object

Database interface class.

Example usage:

db = DBI(dbi='sqlite', server=dbfile, numpy=False, verbose=True)
-db = DBI(dbi='sybase', server='sybase', user='aca_ops', database='aca')
-db = DBI(dbi='sybase')   # Use defaults (same as above)
 
-
Parameters
+
Parameters:
    -
  • dbi – Database interface name (sqlite, sybase)

  • +
  • dbi – Database interface name (sqlite)

  • server – Server name (or file name for sqlite)

  • user – User name (optional)

  • -
  • passwd – Password (optional). Read from aspect authorization if required and not supplied.

  • -
  • database – Database name for sybase (default = SKA_DATABASE env. or package default ‘aca’).

  • autocommit – Automatically commit after each transaction. Slower but easier to code.

  • numpy – Return multirow results as numpy.recarray; input vals can be numpy types

  • verbose – Print transaction info

  • authdir – Directory containing authorization files

-
Return type
+
Return type:

DBI object

@@ -127,14 +120,14 @@

Classesvals are supplied they will be applied to each of the commands.

-
Parameters
+
Parameters:
  • expr – SQL expression to execute

  • vals – Values associated with the expression (optional)

  • commit – Commit after executing C{expr} (default = self.autocommit)

-
Return type
+
Return type:

None

@@ -150,13 +143,13 @@

Classes -
Parameters
+
Parameters:
  • expr – SQL expression to execute

  • vals – Values associated with the expression (optional)

-
Return type
+
Return type:

Generator that will get one row of database as dict() via next()

@@ -172,13 +165,13 @@

Classes -
Parameters
+
Parameters:
  • expr – SQL expression to execute

  • vals – Values associated with the expression (optional)

-
Return type
+
Return type:

All rows of database as numpy.rec.recarray or list of dicts, depending on self.numpy

@@ -195,13 +188,13 @@

Classes -
Parameters
+
Parameters:
  • expr – SQL expression to execute

  • vals – Values associated with the expression (optional)

-
Return type
+
Return type:

One row of database as dict()

@@ -212,7 +205,7 @@

Classesinsert(row, tablename, replace=False, commit=None)[source]

Insert data row into table tablename.

-
Parameters
+
Parameters:
@@ -240,8 +233,22 @@

Classes

Page Contents

@@ -270,7 +277,7 @@

This Page

Back to Top

© Copyright 2020, Tom Aldcroft.
- Created using Sphinx 4.2.0.   + Created using Sphinx 6.1.3.  

diff --git a/docs/objects.inv b/docs/objects.inv index 73b41cb..e2b5bd2 100644 Binary files a/docs/objects.inv and b/docs/objects.inv differ diff --git a/docs/py-modindex.html b/docs/py-modindex.html index bf17f82..9905bc6 100644 --- a/docs/py-modindex.html +++ b/docs/py-modindex.html @@ -1,18 +1,17 @@ - + - Python Module Index — ska_dbi 5.0.0 documentation + Python Module Index — ska_dbi 5.1.0 documentation - - + @@ -49,7 +48,7 @@

Navigation

  • - ska_dbi 5.0.0 documentation + ska_dbi 5.1.0 documentation »
  • @@ -110,7 +109,7 @@

    Python Module Index

    Back to Top

    © Copyright 2020, Tom Aldcroft.
    - Created using Sphinx 4.2.0.   + Created using Sphinx 6.1.3.  

    diff --git a/docs/search.html b/docs/search.html index 98b501b..7f4b6b1 100644 --- a/docs/search.html +++ b/docs/search.html @@ -1,19 +1,18 @@ - + - Search — ska_dbi 5.0.0 documentation + Search — ska_dbi 5.1.0 documentation - - + @@ -47,7 +46,7 @@

    Navigation

    • - ska_dbi 5.0.0 documentation + ska_dbi 5.1.0 documentation »
    • @@ -109,7 +108,7 @@

      Search

      Back to Top

      © Copyright 2020, Tom Aldcroft.
      - Created using Sphinx 4.2.0.   + Created using Sphinx 6.1.3.  

      diff --git a/docs/searchindex.js b/docs/searchindex.js index 345ba16..4b082d0 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["index"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.viewcode":1,sphinx:56},filenames:["index.rst"],objects:{"ska_dbi.DBI":{DBI:[0,1,1,""],_denumpy:[0,3,1,""]},"ska_dbi.DBI.DBI":{commit:[0,2,1,""],execute:[0,2,1,""],fetch:[0,2,1,""],fetchall:[0,2,1,""],fetchone:[0,2,1,""],insert:[0,2,1,""]},ska_dbi:{DBI:[0,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function"},terms:{"1":0,"5":0,"default":0,"return":0,"true":0,"try":0,If:0,One:0,_denumpi:0,abov:0,aca:0,aca_op:0,access:0,account:0,after:0,all:0,alreadi:0,alwai:0,appli:0,ar:0,arg:0,arrai:0,aspect:0,aspect_author:0,associ:0,authdir:0,author:0,autocommit:0,automat:0,base:0,between:0,c:0,can:0,code:0,column:0,command:0,commit:0,connect:0,contain:0,convert:0,cursor:0,data:0,databas:0,db:0,dbfile:0,dbi:0,depend:0,dict:0,differ:0,directori:0,each:0,easier:0,end:0,env:0,exampl:0,execut:0,exist:0,expr:0,express:0,fals:0,featur:0,fetch:0,fetchal:0,fetchon:0,file:0,first:0,from:0,gener:0,get:0,handl:0,info:0,inform:0,input:0,insert:0,integr:0,interfac:0,kwarg:0,line:0,list:0,method:0,mode:0,multipl:0,multirow:0,name:0,nativ:0,next:0,none:0,numpi:0,object:0,one:0,option:0,output:0,over:0,packag:0,paramet:0,passwd:0,password:0,possibl:0,print:0,proj:0,provid:0,python:0,queri:0,read:0,rec:0,recarrai:0,record:0,replac:0,requir:0,result:0,row:0,run:0,s:0,same:0,self:0,semicolon:0,separ:0,server:0,show:0,simpl:0,ska:0,ska_databas:0,slower:0,smooth:0,sot:0,sourc:0,sql:0,sqlite:0,suppli:0,support:0,sybas:0,syntax:0,t:0,tabl:0,tablenam:0,thei:0,them:0,thi:0,time:0,tolist:0,transact:0,type:0,typic:0,us:0,usag:0,user:0,val:0,valu:0,verbos:0,via:0,x:0},titles:["ska_dbi"],titleterms:{"class":0,"function":0,ska_dbi:0}}) \ No newline at end of file +Search.setIndex({"docnames": ["index"], "filenames": ["index.rst"], "titles": ["ska_dbi"], "terms": {"provid": 0, "simpl": 0, "method": 0, "databas": 0, "access": 0, "data": 0, "insert": 0, "featur": 0, "sqlite": 0, "connect": 0, "ar": 0, "support": 0, "integr": 0, "numpi": 0, "record": 0, "arrai": 0, "verbos": 0, "mode": 0, "show": 0, "transact": 0, "inform": 0, "dbi": 0, "_denumpi": 0, "x": 0, "sourc": 0, "try": 0, "us": 0, "tolist": 0, "convert": 0, "nativ": 0, "python": 0, "type": 0, "": 0, "can": 0, "t": 0, "typic": 0, "handl": 0, "val": 0, "none": 0, "server": 0, "true": 0, "autocommit": 0, "fals": 0, "kwarg": 0, "base": 0, "object": 0, "interfac": 0, "exampl": 0, "usag": 0, "db": 0, "dbfile": 0, "paramet": 0, "name": 0, "file": 0, "user": 0, "option": 0, "automat": 0, "commit": 0, "after": 0, "each": 0, "slower": 0, "easier": 0, "code": 0, "return": 0, "multirow": 0, "result": 0, "recarrai": 0, "input": 0, "print": 0, "info": 0, "authdir": 0, "directori": 0, "contain": 0, "author": 0, "execut": 0, "expr": 0, "run": 0, "self": 0, "cursor": 0, "possibl": 0, "output": 0, "multipl": 0, "command": 0, "separ": 0, "them": 0, "semicolon": 0, "end": 0, "line": 0, "If": 0, "suppli": 0, "thei": 0, "appli": 0, "sql": 0, "express": 0, "valu": 0, "associ": 0, "c": 0, "default": 0, "fetch": 0, "gener": 0, "one": 0, "row": 0, "time": 0, "arg": 0, "column": 0, "get": 0, "dict": 0, "via": 0, "next": 0, "fetchal": 0, "all": 0, "1": 0, "5": 0, "rec": 0, "list": 0, "depend": 0, "fetchon": 0, "thi": 0, "alwai": 0, "first": 0, "queri": 0, "One": 0, "tablenam": 0, "replac": 0, "tabl": 0, "alreadi": 0, "exist": 0}, "objects": {"ska_dbi": [[0, 0, 0, "-", "DBI"]], "ska_dbi.DBI": [[0, 1, 1, "", "DBI"], [0, 3, 1, "", "_denumpy"]], "ska_dbi.DBI.DBI": [[0, 2, 1, "", "commit"], [0, 2, 1, "", "execute"], [0, 2, 1, "", "fetch"], [0, 2, 1, "", "fetchall"], [0, 2, 1, "", "fetchone"], [0, 2, 1, "", "insert"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:method", "3": "py:function"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "method", "Python method"], "3": ["py", "function", "Python function"]}, "titleterms": {"ska_dbi": 0, "function": 0, "class": 0}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 8, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1, "sphinx": 57}, "alltitles": {"ska_dbi": [[0, "module-ska_dbi.DBI"]], "Functions": [[0, "functions"]], "Classes": [[0, "classes"]]}, "indexentries": {"dbi (class in ska_dbi.dbi)": [[0, "ska_dbi.DBI.DBI"]], "_denumpy() (in module ska_dbi.dbi)": [[0, "ska_dbi.DBI._denumpy"]], "commit() (ska_dbi.dbi.dbi method)": [[0, "ska_dbi.DBI.DBI.commit"]], "execute() (ska_dbi.dbi.dbi method)": [[0, "ska_dbi.DBI.DBI.execute"]], "fetch() (ska_dbi.dbi.dbi method)": [[0, "ska_dbi.DBI.DBI.fetch"]], "fetchall() (ska_dbi.dbi.dbi method)": [[0, "ska_dbi.DBI.DBI.fetchall"]], "fetchone() (ska_dbi.dbi.dbi method)": [[0, "ska_dbi.DBI.DBI.fetchone"]], "insert() (ska_dbi.dbi.dbi method)": [[0, "ska_dbi.DBI.DBI.insert"]], "module": [[0, "module-ska_dbi.DBI"]], "ska_dbi.dbi": [[0, "module-ska_dbi.DBI"]]}}) \ No newline at end of file