-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.html
More file actions
176 lines (159 loc) · 8.25 KB
/
install.html
File metadata and controls
176 lines (159 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Installation — xdapy 0.9.0 documentation</title>
<link rel="stylesheet" href="_static/haiku.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/print.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.9.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/theme_extras.js"></script>
<link rel="top" title="xdapy 0.9.0 documentation" href="index.html" />
<link rel="next" title="The data model" href="datamodel.html" />
<link rel="prev" title="Introduction" href="intro.html" />
</head>
<body>
<div class="header"><h1 class="heading"><a href="index.html">
<span>xdapy 0.9.0 documentation</span></a></h1>
<h2 class="heading"><span>Installation</span></h2>
</div>
<div class="topnav">
<p>
«  <a href="intro.html">Introduction</a>
  ::  
<a class="uplink" href="index.html">Contents</a>
  ::  
<a href="datamodel.html">The data model</a>  »
</p>
</div>
<div class="content">
<div class="section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h1>
<div class="section" id="requirements">
<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>Python 2.6 / 2.7</li>
<li>SQLAlchemy</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">SQLAlchemy must be of version 0.7 or above</p>
</div>
<div class="section" id="additionally-for-postgresql">
<h3>Additionally for PostgreSQL<a class="headerlink" href="#additionally-for-postgresql" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>psycopg2 (Python–PostgreSQL Database Adapter)</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Psycopg2 must be of version 2.4.1 or above due to a bug concerning PostgreSQL handling of binary data.
See also <a class="reference external" href="http://initd.org/psycopg/docs/faq.html#problems-with-type-conversions">http://initd.org/psycopg/docs/faq.html#problems-with-type-conversions</a>. To it needs to be installed
from source, the packages libpq and libpq-dev are required as well.</p>
</div>
<ul class="simple">
<li>A postgresql database</li>
</ul>
</div>
<div class="section" id="additionally-for-sqlite">
<h3>Additionally for SQLite<a class="headerlink" href="#additionally-for-sqlite" title="Permalink to this headline">¶</a></h3>
<p>(built into Python)</p>
</div>
</div>
<div class="section" id="setup-step-1">
<h2>Setup Step 1<a class="headerlink" href="#setup-step-1" title="Permalink to this headline">¶</a></h2>
<p>Install the required components from their respective web pages or using a package manager if your system supports one.
Instructions, advice and support for the installation of the third party components can be obtained by their providers.
Then, checkout Xdapy from its repository on <a class="reference external" href="https://github.com/xdapy/xdapy.git">https://github.com/xdapy/xdapy.git</a>
The path to your local copy of Xdapy must be added to the <tt class="xref py py-obj docutils literal"><span class="pre">PYTHONPATH</span></tt>.</p>
</div>
<div class="section" id="basic-test">
<h2>Basic Test<a class="headerlink" href="#basic-test" title="Permalink to this headline">¶</a></h2>
<p>Testing is conveniently done using nosetests. Here, we first test the basic installation
of Python and SQLAlchemy using a SQLite in-memory database.:</p>
<div class="highlight-python"><pre>cd path/to/xdapy/
nosetests</pre>
</div>
<p>Python’s build in unittests can be used alternatively starting with Python2.7::3</p>
<blockquote>
<div>python -m unittest discover</div></blockquote>
<p>If the tests worked properly you are almost finished with the setup. There is only one more step.</p>
</div>
<div class="section" id="setup-step-2">
<h2>Setup Step 2<a class="headerlink" href="#setup-step-2" title="Permalink to this headline">¶</a></h2>
<p>With the second step we define the default database that Xdapy will use.
Create an initialization file that is located in a hidden directory below your home folder:</p>
<div class="highlight-python"><pre>cd ~
mkdir .xdapy
cd .xdapy</pre>
</div>
<p>Furthermore, the file must be called <tt class="xref py py-obj docutils literal"><span class="pre">engine.ini</span></tt> and it can contain several profiles that reference to different databases:</p>
<div class="highlight-python"><pre>[default]
url = sqlite:///xdapy.db
[test]
url = sqlite://
[demo]
url = sqlite:///demo.db</pre>
</div>
<p>The default profile must be specified.
The test profile will only be used for the tests.
The in-memory SQLite database from this example is the same option as when no test profile is specified.
A third profile is applied with the demo code. This way, the database that will be used in the real application is not touched.
If you wish to use Xdapy with PostgreSQL, then the tests should be rerun with an PostgreSQL database.
Otherwise, you can skip the next paragraph and continue with step 3.</p>
</div>
<div class="section" id="test-with-postresql">
<h2>Test with PostreSQL<a class="headerlink" href="#test-with-postresql" title="Permalink to this headline">¶</a></h2>
<p>Before we can run the tests for a PostgreSQL database or use one as default, these databases need to be created.
Run the following commands on the console to create the databases locally:</p>
<div class="highlight-python"><pre>createdb dbname
createdb testdbname</pre>
</div>
<p>Then, adapt the <tt class="xref py py-obj docutils literal"><span class="pre">engine.ini</span></tt>:</p>
<div class="highlight-python"><pre>[default]
url = postgresql://user:pass@host/dbname
[test]
url = postgresql://user:pass@host/testdbname</pre>
</div>
<p>and finally rerun the tests as described above.</p>
</div>
<div class="section" id="setup-step-3">
<h2>Setup Step 3<a class="headerlink" href="#setup-step-3" title="Permalink to this headline">¶</a></h2>
<p>At this point the general setup is running.
You will only need to create the initial database table structure, and to do so you actually use Xdapy for the first time.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">xdapy</span> <span class="kn">import</span> <span class="n">Connection</span>
<span class="n">connection</span> <span class="o">=</span> <span class="n">Connection</span><span class="o">.</span><span class="n">profile</span><span class="p">(</span><span class="s">"demo"</span><span class="p">)</span> <span class="c"># use demo profile</span>
<span class="n">connection</span><span class="o">.</span><span class="n">create_tables</span><span class="p">()</span>
</pre></div>
</div>
<p>The example creates the tables for the “demo” profile. The same needs to be done for the default profile.
Now, the installation is finished and the database can be used.</p>
</div>
</div>
</div>
<div class="bottomnav">
<p>
«  <a href="intro.html">Introduction</a>
  ::  
<a class="uplink" href="index.html">Contents</a>
  ::  
<a href="datamodel.html">The data model</a>  »
</p>
</div>
<div class="footer">
© Copyright 2012, Hannah Dold, Rike-Benjamin Schuppner.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>