Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
slapos.core
Commits
759b5088
Commit
759b5088
authored
Feb 20, 2018
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.collect: allow connect without call boostrap, set timeout option
parent
62627b23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
slapos/collect/db.py
slapos/collect/db.py
+5
-3
slapos/util.py
slapos/util.py
+5
-2
No files found.
slapos/collect/db.py
View file @
759b5088
...
@@ -121,15 +121,17 @@ class Database:
...
@@ -121,15 +121,17 @@ class Database:
" date, time) values "
\
" date, time) values "
\
"( '%s', '%s', %s, %s, %s, %s, '%s', '%s' )"
"( '%s', '%s', %s, %s, %s, %s, '%s', '%s' )"
def
__init__
(
self
,
directory
=
None
):
def
__init__
(
self
,
directory
=
None
,
create
=
True
,
timeout
=
None
):
assert
self
.
database_name
is
not
None
assert
self
.
database_name
is
not
None
self
.
uri
=
os
.
path
.
join
(
directory
,
self
.
database_name
)
self
.
uri
=
os
.
path
.
join
(
directory
,
self
.
database_name
)
self
.
connection
=
None
self
.
connection
=
None
self
.
cursor
=
None
self
.
cursor
=
None
self
.
_bootstrap
()
self
.
timeout
=
timeout
if
create
:
self
.
_bootstrap
()
def
connect
(
self
):
def
connect
(
self
):
self
.
connection
=
sqlite_connect
(
self
.
uri
)
self
.
connection
=
sqlite_connect
(
self
.
uri
,
timeout
=
self
.
timeout
)
self
.
cursor
=
self
.
connection
.
cursor
()
self
.
cursor
=
self
.
connection
.
cursor
()
def
commit
(
self
):
def
commit
(
self
):
...
...
slapos/util.py
View file @
759b5088
...
@@ -97,7 +97,10 @@ def string_to_boolean(string):
...
@@ -97,7 +97,10 @@ def string_to_boolean(string):
raise
ValueError
(
'%s is neither True nor False.'
%
string
)
raise
ValueError
(
'%s is neither True nor False.'
%
string
)
def
sqlite_connect
(
dburi
):
def
sqlite_connect
(
dburi
,
timeout
=
None
):
conn
=
sqlite3
.
connect
(
dburi
)
connect_kw
=
{}
if
timeout
is
not
None
:
connect_kw
[
'timeout'
]
=
timeout
conn
=
sqlite3
.
connect
(
dburi
,
**
connect_kw
)
conn
.
text_factory
=
str
# allow 8-bit strings
conn
.
text_factory
=
str
# allow 8-bit strings
return
conn
return
conn
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment