sqlutilpy 0.25.0__tar.gz → 0.27.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlutilpy
3
- Version: 0.25.0
3
+ Version: 0.27.0
4
4
  Summary: Database query code returning numpy arrays
5
5
  Author-email: "Sergey E. Koposov" <skoposov@ed.ac.uk>
6
6
  License: BSD
@@ -44,11 +44,11 @@ pip install sqlutilpy
44
44
  Throughout this readme, I will assume that if you are using PostgreSQL, then
45
45
  the .pgpass file ( https://www.postgresql.org/docs/11/libpq-pgpass.html )
46
46
  has been created with your login/password details for Postgresql. If that is not the case, many of the
47
- commands given below will also need user='....' and password='...' options
47
+ commands given below will also need user='....' and password='...' options.
48
48
 
49
49
  ## Connection information
50
50
 
51
- Most of the sqlutilpy commands require hostname, database name, user etc.
51
+ Most of the `sqlutilpy` commands require hostname, database name.
52
52
  If you don't want to always type it, you can use standard PostgreSQL environment variables
53
53
  like PGPORT, PGDATABASE, PGUSER, PGHOST for the port, database name, user name and hostname
54
54
  of the connection.
@@ -56,7 +56,8 @@ of the connection.
56
56
 
57
57
  ## Querying the database and retrieving the results
58
58
 
59
- This command will run the query and put the columns into variables ra,dec
59
+ This command will run the query and put the columns into variables ra,dec:
60
+
60
61
  ```python
61
62
  import sqlutilpy
62
63
  ra,dec = squtilpy.get('select ra,dec from mytable',
@@ -64,23 +65,28 @@ ra,dec = squtilpy.get('select ra,dec from mytable',
64
65
  db='THE_NAME_OF_MY_DB')
65
66
  ```
66
67
 
67
- By default sqlutilpy.get executes the query and returns the tuple with
68
- results. You can return the results as dictionary using asDict option.
68
+ By default `sqlutilpy.get` executes the query and returns the tuple with
69
+ arrays. One array for each column in the query result.
70
+ You can return the results as dictionary using `asDict` option.
69
71
 
70
72
  ## Uploading your arrays as column in a table
71
73
 
74
+ You can use `sqlutilpy.upload` to upload your arrays as columns in a table.
75
+
72
76
  ```python
73
77
  x = np.arange(10)
74
78
  y = x**.5
75
79
  sqlutilpy.upload('mytable',(x,y),('xcol','ycol'))
76
80
  ```
77
- This will create a table called mytable with columns xcol and ycol
81
+ This will create a table called `mytable` with columns `xcol` and `ycol`
78
82
 
79
83
  ## Join query involving your local data and the database table
80
84
 
81
- Imagine you have arrays myid and y and you want to to extract all the
82
- information from somebigtable for objects with id=myid. In principle
83
- you could upload the arrays in the DB and run a query, but local_join function does that for you.
85
+ Sometimes it is beneficial to run a join query involving your local data and the data in the database.
86
+
87
+ Imagine you have arrays `myid` and `y` and you want to extract all the
88
+ information from `somebigtable` for objects with `id=myid`. In principle,
89
+ you could upload the arrays in the DB and run a query, but `local_join` function does that for you.
84
90
 
85
91
  ```python
86
92
  myid = np.arange(10)
@@ -91,15 +97,14 @@ R=sqlutilpy.local_join('''select * from mytmptable as m,
91
97
  'mytmptable',(myid, y),('myid','ycol'))
92
98
  ```
93
99
 
94
- It executes a query as if you arrays were in mytmptable. (behind the scenes
95
- it uploads the data to the db and runs a query)
100
+ It executes a query as if your arrays were in `mytmptable`. What happens behind the scenes
101
+ is that it uploads the data to the database and runs a query against it.
96
102
 
97
103
  ## Keeping the connection open.
98
104
 
99
105
  Often it is beneficial to preserve an open connection to the database. You can do that if you first
100
- obtain the connection using sqlutilpy.getConnection() and then provide it directly
101
- to sqlutil.get() and friends using conn=conn argument
102
- ```python
106
+ obtain the connection using `sqlutilpy.getConnection()` and then provide it directly
107
+ to `sqlutil.get()` and similar commands using `conn=` keyword:
103
108
  conn = sqlutilpy.getConnection(db='mydb', user='meuser', password='something', host='hostname')
104
109
  R= sqlutilpy.get('select 1', conn=conn)
105
110
  R1= sqlutilpy.get('select 1', conn=conn)
@@ -107,5 +112,5 @@ R1= sqlutilpy.get('select 1', conn=conn)
107
112
 
108
113
  # How to cite the software
109
114
 
110
- If you use this package, please cite it through zenodo https://doi.org/10.5281/zenodo.6867957
115
+ If you use this package, please cite it through Zenodo https://doi.org/10.5281/zenodo.5160118
111
116
 
@@ -24,11 +24,11 @@ pip install sqlutilpy
24
24
  Throughout this readme, I will assume that if you are using PostgreSQL, then
25
25
  the .pgpass file ( https://www.postgresql.org/docs/11/libpq-pgpass.html )
26
26
  has been created with your login/password details for Postgresql. If that is not the case, many of the
27
- commands given below will also need user='....' and password='...' options
27
+ commands given below will also need user='....' and password='...' options.
28
28
 
29
29
  ## Connection information
30
30
 
31
- Most of the sqlutilpy commands require hostname, database name, user etc.
31
+ Most of the `sqlutilpy` commands require hostname, database name.
32
32
  If you don't want to always type it, you can use standard PostgreSQL environment variables
33
33
  like PGPORT, PGDATABASE, PGUSER, PGHOST for the port, database name, user name and hostname
34
34
  of the connection.
@@ -36,7 +36,8 @@ of the connection.
36
36
 
37
37
  ## Querying the database and retrieving the results
38
38
 
39
- This command will run the query and put the columns into variables ra,dec
39
+ This command will run the query and put the columns into variables ra,dec:
40
+
40
41
  ```python
41
42
  import sqlutilpy
42
43
  ra,dec = squtilpy.get('select ra,dec from mytable',
@@ -44,23 +45,28 @@ ra,dec = squtilpy.get('select ra,dec from mytable',
44
45
  db='THE_NAME_OF_MY_DB')
45
46
  ```
46
47
 
47
- By default sqlutilpy.get executes the query and returns the tuple with
48
- results. You can return the results as dictionary using asDict option.
48
+ By default `sqlutilpy.get` executes the query and returns the tuple with
49
+ arrays. One array for each column in the query result.
50
+ You can return the results as dictionary using `asDict` option.
49
51
 
50
52
  ## Uploading your arrays as column in a table
51
53
 
54
+ You can use `sqlutilpy.upload` to upload your arrays as columns in a table.
55
+
52
56
  ```python
53
57
  x = np.arange(10)
54
58
  y = x**.5
55
59
  sqlutilpy.upload('mytable',(x,y),('xcol','ycol'))
56
60
  ```
57
- This will create a table called mytable with columns xcol and ycol
61
+ This will create a table called `mytable` with columns `xcol` and `ycol`
58
62
 
59
63
  ## Join query involving your local data and the database table
60
64
 
61
- Imagine you have arrays myid and y and you want to to extract all the
62
- information from somebigtable for objects with id=myid. In principle
63
- you could upload the arrays in the DB and run a query, but local_join function does that for you.
65
+ Sometimes it is beneficial to run a join query involving your local data and the data in the database.
66
+
67
+ Imagine you have arrays `myid` and `y` and you want to extract all the
68
+ information from `somebigtable` for objects with `id=myid`. In principle,
69
+ you could upload the arrays in the DB and run a query, but `local_join` function does that for you.
64
70
 
65
71
  ```python
66
72
  myid = np.arange(10)
@@ -71,15 +77,14 @@ R=sqlutilpy.local_join('''select * from mytmptable as m,
71
77
  'mytmptable',(myid, y),('myid','ycol'))
72
78
  ```
73
79
 
74
- It executes a query as if you arrays were in mytmptable. (behind the scenes
75
- it uploads the data to the db and runs a query)
80
+ It executes a query as if your arrays were in `mytmptable`. What happens behind the scenes
81
+ is that it uploads the data to the database and runs a query against it.
76
82
 
77
83
  ## Keeping the connection open.
78
84
 
79
85
  Often it is beneficial to preserve an open connection to the database. You can do that if you first
80
- obtain the connection using sqlutilpy.getConnection() and then provide it directly
81
- to sqlutil.get() and friends using conn=conn argument
82
- ```python
86
+ obtain the connection using `sqlutilpy.getConnection()` and then provide it directly
87
+ to `sqlutil.get()` and similar commands using `conn=` keyword:
83
88
  conn = sqlutilpy.getConnection(db='mydb', user='meuser', password='something', host='hostname')
84
89
  R= sqlutilpy.get('select 1', conn=conn)
85
90
  R1= sqlutilpy.get('select 1', conn=conn)
@@ -87,5 +92,5 @@ R1= sqlutilpy.get('select 1', conn=conn)
87
92
 
88
93
  # How to cite the software
89
94
 
90
- If you use this package, please cite it through zenodo https://doi.org/10.5281/zenodo.6867957
95
+ If you use this package, please cite it through Zenodo https://doi.org/10.5281/zenodo.5160118
91
96