Re: [Tutor] databases

2011-09-12 Thread Prasad, Ramit
> Also I suspect you don't really need to download the full Developers 
>Tools(XCode) you could probably just use the gcc compiler which
>is much smaller from Macports or Fink.


The last I checked, Macports required XCode compiler to build/install itself 
(and requires XCode to be updated on OS upgrade). This might have changed. I 
have never used Fink, so not sure if that is different.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-11 Thread Alan Gauld

On 11/09/11 06:19, Alejandro Companioni wrote:


I had the same thoughts at first: OS X is just BSD! This can't be too
different from a Linux installation, right?

There are a number of problems with mysql-python--chiefly its poor
maintenance. I'll link to a nine (!) step guide on installing
mysql-python on Mac as an example:

http://friendlybit.com/tutorial/install-mysql-python-on-mac-os-x-leopard/



Hmm, That's not really that difficult, about the same as on any standard 
Unix system. I guess its much harder than the usual MacOS install 
though, so for a Mac user would seem pretty bad.



At Step 9 the author suggests using setuptools even though it will fail,
and you'd actually have to patch a (old, well-documented) bug yourself.


Yeah, but he could have shortened it slightly by telling you about the 
types.h bug at step 7 rather than wait till it failed!... But its a pity 
they MySQL folks haven't fixed that yet. Then it would only have been a 
7 step process.


Also I suspect you don't really need to download the full Developers 
Tools(XCode) you could probably just use the gcc compiler which

is much smaller from Macports or Fink.

OTOH IF you are using Python on a Mac then using XCode as your IDE is
a good idea! Especially if you want to write Mac GUIs. And if you 
already had XCode installed then the process would go dowen to 5 
steps... And as one commentator said the Developer tools are on the 
MacOS DVD, you don't need to download them and register on the site 
(although that's a good idea too)


> Not a good start for a new Python coder,

I can see it might be intimidating to a Mac user trying to get into 
programming. But OTOH wouldn't setting up a Linux VM be even more

steps?

But sadly as a programmer that kind of installation routine is
fairly normal(*). Developers are expected to be fairly savvy
about how their computer works so slick installation tools
are rarely a high priority... And in fact some developers don't like 
fancy installers that do all the setup for them because they have set up 
their machines "just so" for their own ends and want complete control. 
You can't please everyone...


(*)I once worked on a project that required Oracle 6 to be installed on 
our Sun server and after two days I got it working. I then documented 
the process for the rest of the team. It was 22 steps and even after 
doing it a half dozen times it still took several hours to complete. 
Thankfully Oracle have improved their installers nowadays! :-)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread Alejandro Companioni

On Sep 10, 2011, at 9:29 PM, tutor-requ...@python.org wrote:

> I've never used MySql on a Mac but I'm curious why it should be so 
> difficult.
> 
> MacOS is just BSD Unix under the GUI so why would be any different
> to any other Unix type system? What were the problems that you encountered?

Hey Alan,

I had the same thoughts at first: OS X is just BSD! This can't be too different 
from a Linux installation, right?

There are a number of problems with mysql-python--chiefly its poor maintenance. 
I'll link to a nine (!) step guide on installing mysql-python on Mac as an 
example:

http://friendlybit.com/tutorial/install-mysql-python-on-mac-os-x-leopard/

At Step 9 the author suggests using setuptools even though it will fail, and 
you'd actually have to patch a (old, well-documented) bug yourself. 

I wish I had found that website sooner, as installing mysql-python on my Mac 
took about 5-6 hours of constant frustration. Not a good start for a new Python 
coder, but if at least one novice skips my experience after reading this email 
then I'll be happy.

-Alejandro___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread ALAN GAULD



> > package that can open a databases without knowing there format?
> So, in case I wasn't clear, the databases are already made by someone else, 
> and the format is beyond my control.  I need/want to learn to manipulate 
> them.  
>

OK, That wasn't clear. And it makes a difference. You need to know the format.

> Most likely they are similar to the Berkeley database

And that makes a much bigger difference because most folks assume by 
'database' you mean a SQL database. Berkeley databases are flat file based 
and there is a module to read them in the Python library, but they don't use 
SQL.

They are more like a random access file mechanism than a relational database.
If that's what you are dealing with then it's a whole lot of different 
references 

you need. I'd start with wikipedia and the [g]dbm module documentation.


HTH,

Alan G.___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread Alan Gauld

On 10/09/11 23:28, Alejandro Companioni wrote:


Just wanted to chime in, because I wish someone had told me this sooner,
but if you're using a Mac, try to steer clear of mysql-python. Setting
it up on a Mac is absolutely infuriating.


I've never used MySql on a Mac but I'm curious why it should be so 
difficult.


MacOS is just BSD Unix under the GUI so why would be any different
to any other Unix type system? What were the problems that you encountered?


If your databases are MySQL-based and you're using a Mac, I'd recommend
setting up a Linux VM to access them with Python (or not using Python at
all). Good luck!


Now that sounds like it should be much more difficult. You'd effectively 
be running a client server setup to a foreign OS

on your own computer but sharing the physical resources...
There must be something really weird about the MacOS setup
to make that easier!

I'm intrigued.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread Andre' Walker-Loud
>> You might look at http://www.sqlalchemy.org/, since it works with most 
>> databases. However if you are new on databases, I think you should start 
>> learning databases basics, choose a database management system (DBMS) 
>> that fit your needs and learn as much as you can about that specific 
>> DBMS. Then you can use SQLAlchemy or specific packagas (MySQL-Python, 
>> PyGreSQL,...) to acces to that DBMS. In addition if you are going to use 
>> frameworks, most of them already have their own tools for DB manipulation.
>> 
> 
> Just wanted to chime in, because I wish someone had told me this sooner, but 
> if you're using a Mac, try to steer clear of mysql-python. Setting it up on a 
> Mac is absolutely infuriating.
> 
> If your databases are MySQL-based and you're using a Mac, I'd recommend 
> setting up a Linux VM to access them with Python (or not using Python at 
> all). Good luck!

Thanks for the warning Alejandro.

Turns out, they live on a linux cluster - but I log in via a Mac, and likely 
will copy locally to play around with.

I figured I could either hack the c++ code built already to manipulate them, or 
use this as an excuse to learn about databases via python.


Andre
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread Andre' Walker-Loud
> > package that can open a databases without knowing there format?
> 
> The Python DB API is pretty good at covering all the common databases but 
> sadly everyone has some slight variances so you do need to know which product 
> you will be using.
> 
> As an example the SQLite package that comes in the standard library - and is 
> a good starter - doesn't require login credentials but Oracle, MySQL etc do. 
> Also Sqllite is stored in a single file accessed via a code library whereas 
> most other SQL databases use multiple files and a server frontend. (That's 
> why there's a connect() function - to connect to the server... in SQLite 
> connect just opens the file!)
> 
> If you are a database noob I'd keep it simple and stick with SQLite, it's 
> powerful enough for most beginner type projects and misses out some of the 
> more complex features of the other packages. Provided you aren't expecting to 
> scale up to 10's of millions of records it will do just fine. Once you 
> understand SQLite moving to MySQL or Firebird or whatever will be an easy 
> next step.

So, in case I wasn't clear, the databases are already made by someone else, and 
the format is beyond my control.  I need/want to learn to manipulate them.  
Most likely they are similar to the Berkeley database (but I don't know what 
this means yet).

Thanks for the help,

Andre
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] databases

2011-09-10 Thread Alejandro Companioni

On Sep 10, 2011, at 6:15 PM, tutor-requ...@python.org wrote:

> You might look at http://www.sqlalchemy.org/, since it works with most 
> databases. However if you are new on databases, I think you should start 
> learning databases basics, choose a database management system (DBMS) 
> that fit your needs and learn as much as you can about that specific 
> DBMS. Then you can use SQLAlchemy or specific packagas (MySQL-Python, 
> PyGreSQL,...) to acces to that DBMS. In addition if you are going to use 
> frameworks, most of them already have their own tools for DB manipulation.
> 

Just wanted to chime in, because I wish someone had told me this sooner, but if 
you're using a Mac, try to steer clear of mysql-python. Setting it up on a Mac 
is absolutely infuriating.

If your databases are MySQL-based and you're using a Mac, I'd recommend setting 
up a Linux VM to access them with Python (or not using Python at all). Good 
luck!

-Alejandro___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread Alan Gauld

On 10/09/11 20:44, Andre' Walker-Loud wrote:

What type of databases? sql server, mysql, sqllite?

well this already helps.  I don't even know.
Do I have to know ahead of time?  Or is there a general database

> package that can open a databases without knowing there format?

The Python DB API is pretty good at covering all the common databases 
but sadly everyone has some slight variances so you do need to know 
which product you will be using.


As an example the SQLite package that comes in the standard library - 
and is a good starter - doesn't require login credentials but Oracle, 
MySQL etc do. Also Sqllite is stored in a single file accessed via a 
code library whereas most other SQL databases use multiple files and a 
server frontend. (That's why there's a connect() function - to connect 
to the server... in SQLite connect just opens the file!)


If you are a database noob I'd keep it simple and stick with SQLite, 
it's powerful enough for most beginner type projects and misses out some 
of the more complex features of the other packages. Provided you aren't 
expecting to scale up to 10's of millions of records it will do just 
fine. Once you understand SQLite moving to MySQL or Firebird or whatever 
will be an easy next step.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread Rafael Durán Castañeda

On 10/09/11 21:44, Andre' Walker-Loud wrote:

What type of databases? sql server, mysql, sqllite?

Hi James,

well this already helps.  I don't even know.  Do I have to know ahead of time?  
Or is there a general database package that can open a databases without 
knowing there format?


Thanks,

Andre
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
You might look at http://www.sqlalchemy.org/, since it works with most 
databases. However if you are new on databases, I think you should start 
learning databases basics, choose a database management system (DBMS) 
that fit your needs and learn as much as you can about that specific 
DBMS. Then you can use SQLAlchemy or specific packagas (MySQL-Python, 
PyGreSQL,...) to acces to that DBMS. In addition if you are going to use 
frameworks, most of them already have their own tools for DB manipulation.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread Andre' Walker-Loud
> 
> What type of databases? sql server, mysql, sqllite?

Hi James,

well this already helps.  I don't even know.  Do I have to know ahead of time?  
Or is there a general database package that can open a databases without 
knowing there format?


Thanks,

Andre
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] databases

2011-09-10 Thread James Reynolds
On Sat, Sep 10, 2011 at 3:39 PM, Andre' Walker-Loud wrote:

> Hi All,
>
> I am completely new to databases as well as using python to access/create
> databases.  I started googling about it and found so much info, I wasn't
> sure where to begin to answer my first question.  So I thought I would query
> this group by asking a question I am sure has been asked before - but you
> all are so friendly, I thought I would give it a try.
>
> I have databases (many of them) which I want to manipulate, averaging data,
> merging databases, etc.
>
> Do I need to install separate modules to access the databases?
>
> Do I need to know the specific style the databases were created in to open
> manipulate them with python (2.7)?  I ask this because with xml files, I was
> able to just use
>
> from xml.dom import minidom
>
> and then by trial and error in an interactive session, I could figure out
> how to walk through the xml file to find what I wanted.  I am wondering if I
> can do something similar with a database, or if there are more pre-defined
> formats.  I do not actually know what format my databases are in (someone
> else wrote the c-code to create them).
>
>
> While waiting for suggestions, I have started to read Alan Gauld's tutorial
> on the subject
>
> http://www.alan-g.me.uk/tutor/index.htm
>
>
>
> Thanks,
>
> Andre
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


What type of databases? sql server, mysql, sqllite?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] databases

2011-09-10 Thread Andre' Walker-Loud
Hi All,

I am completely new to databases as well as using python to access/create 
databases.  I started googling about it and found so much info, I wasn't sure 
where to begin to answer my first question.  So I thought I would query this 
group by asking a question I am sure has been asked before - but you all are so 
friendly, I thought I would give it a try.

I have databases (many of them) which I want to manipulate, averaging data, 
merging databases, etc.

Do I need to install separate modules to access the databases?

Do I need to know the specific style the databases were created in to open 
manipulate them with python (2.7)?  I ask this because with xml files, I was 
able to just use 

from xml.dom import minidom

and then by trial and error in an interactive session, I could figure out how 
to walk through the xml file to find what I wanted.  I am wondering if I can do 
something similar with a database, or if there are more pre-defined formats.  I 
do not actually know what format my databases are in (someone else wrote the 
c-code to create them).


While waiting for suggestions, I have started to read Alan Gauld's tutorial on 
the subject

http://www.alan-g.me.uk/tutor/index.htm



Thanks,

Andre


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
Oh, stupid me forgot the error message. Well, for some odd reason it works
now, but there are still some issues. When I tried it just a few minutes
ago, it worked fine, it seemed to me.
If anyone have any tips, please let me know. Thanks everyone for the tips.

On Tue, Aug 24, 2010 at 2:24 PM,
wrote:

>
>
> aug dawg  wrote on 08/24/2010 01:55:14 PM:
>
>
> > Now it says that the variable adder is not defined. Does anyone know
> about this?
> >
> It is best if you send the full error message, it helps pinpoint the
> problem.
> my copy of your code was:
> database = []
> datafile = open('/home/~/the-db/data')
> for line in datafile:
> database.append(line)
>
> while tf2 != True:
> command = raw_input("Enter a command. >> ")
>
> while tf != True:
> if "add" in command:
> adder = raw_input("What to add? >> ")
> data_base.append(adder)
> if "no more" in adder:
> tf = True
>
> if "read" in command:
> print(database)
> if "search" in command:
> searcher = raw_input("Enter term to search >> ")
> if searcher in database:
> # Figure this out.
> if "exit database" in command:
> print "Bye!"
> sys.exit()
>
> I am not sure what you typed in as your command or how your source was
> formatted (the tabs did not come through to me) so I cannot say for sure.
> If "add" was not your command, adder does not get defined.
> My guess is that you typed in a different command so you skipped the
> assignment but are checking for "no more" in adder, or attempting to append
> adder.  This would trigger that error.  Did you get the "What to add? >>"
> message?
>
> Chris
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread christopher . henk
aug dawg  wrote on 08/24/2010 01:55:14 PM:

> Now it says that the variable adder is not defined. Does anyone know 
about this?
> 
It is best if you send the full error message, it helps pinpoint the 
problem.
my copy of your code was:
database = []
datafile = open('/home/~/the-db/data')
for line in datafile:
database.append(line)

while tf2 != True:
command = raw_input("Enter a command. >> ")

while tf != True:
if "add" in command:
adder = raw_input("What to add? >> ")
data_base.append(adder)
if "no more" in adder:
tf = True

if "read" in command:
print(database)
if "search" in command:
searcher = raw_input("Enter term to search >> ")
if searcher in database:
# Figure this out.
if "exit database" in command:
print "Bye!"
sys.exit()

I am not sure what you typed in as your command or how your source was 
formatted (the tabs did not come through to me) so I cannot say for sure.
If "add" was not your command, adder does not get defined. 
My guess is that you typed in a different command so you skipped the 
assignment but are checking for "no more" in adder, or attempting to 
append adder.  This would trigger that error.  Did you get the "What to 
add? >>" message?

Chris___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread Alan Gauld


"aug dawg"  wrote


   select-db = raw_input("Which database to add to? >> ")
SyntaxError: can't assign to operator

I think it might be the >> at the end, but when I try it in the 
Python

interpreter, it works fine.


You have a minus sign in your variable name - at least thats
how Python sees it...


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
Now it says that the variable adder is not defined. Does anyone know about
this?


On Tue, Aug 24, 2010 at 1:40 PM,
wrote:

>
> aug dawg wrote on 08/24/2010 01:13:01 PM:
>
>
> > It's not catching that, but I haven't gotten there with the bugs yet. One
> more thing I can't figure out.
>
> >
> > line 11
> > select-db = raw_input("Which database to add to? >> ")
> > SyntaxError: can't assign to operator
> >
> > I think it might be the >> at the end, but when I try it in the Python
> interpreter, it works fine.
> >
> The error is triggered by your variable name.  You can't use a dash, Python
> is interpreting that as a minus sign.  You can use the underscore "_"
> instead.
>
> more here:
> http://www.pasteur.fr/formation/infobio/python/ch02s03.html
> http://docs.python.org/reference/lexical_analysis.html#identifiers
>
>
> Chris
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread christopher . henk
aug dawg wrote on 08/24/2010 01:13:01 PM:

> It's not catching that, but I haven't gotten there with the bugs yet. 
One more thing I can't figure out.
> 
> line 11
> select-db = raw_input("Which database to add to? >> ")
> SyntaxError: can't assign to operator
> 
> I think it might be the >> at the end, but when I try it in the Python 
interpreter, it works fine.
> 
The error is triggered by your variable name.  You can't use a dash, 
Python is interpreting that as a minus sign.  You can use the underscore 
"_" instead.

more here:
http://www.pasteur.fr/formation/infobio/python/ch02s03.html
http://docs.python.org/reference/lexical_analysis.html#identifiers


Chris___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
It's not catching that, but I haven't gotten there with the bugs yet. One
more thing I can't figure out.

line 11
select-db = raw_input("Which database to add to? >> ")
SyntaxError: can't assign to operator

I think it might be the >> at the end, but when I try it in the Python
interpreter, it works fine.

On Tue, Aug 24, 2010 at 1:07 PM, Marc Tompkins wrote:

> On Tue, Aug 24, 2010 at 12:44 PM, aug dawg  wrote:
>
>>  if searcher in database:
>>> # Figure this out.
>>>
>>> You need some sort of actual Python statement there as a placeholder -
> even just "print()".
>
> --
> www.fsrtechnologies.com
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
Oh yeah. That was just a comment that I forgot to take out.


On Tue, Aug 24, 2010 at 1:01 PM, Walter Prins  wrote:

>
>
> On 24 August 2010 17:47, aug dawg  wrote:
>
>>  if searcher in database:
>>>  # Figure this out.
>>>  if "exit database" in command:
>>> print "Bye!"
>>> sys.exit()
>>>
>>
> The first thing that caught my eye was the "#figure me out" line -- python
> is expecting a statement there, a comment doesn't count.  You can use "pass"
> for the time being.  (See
> http://docs.python.org/reference/simple_stmts.html#grammar-token-pass_stmt
> )
>
> Walter
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread Marc Tompkins
On Tue, Aug 24, 2010 at 12:44 PM, aug dawg  wrote:

>  if searcher in database:
>> # Figure this out.
>>
>> You need some sort of actual Python statement there as a placeholder -
even just "print()".

-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread Che M

> The other day, I wrote a little database just to fiddle around, 
> but when I try to run it it says that it has an unexpected indent. 
> From what I can tell, it doesn't. Here's the code. I'm using SPE.

In the future, you should copy/paste error message you get into
your email.  This way it indicates to others the exact problem you
had.

One thing I noticed that is wrong in your code is this line:

if searcher in database:# Figure this out.  
The comment doesn't count as a line of interpretable code, so
you have nothing in this code block.  If you want to do that, use
pass, like:

if searcher in database:pass
# Figure this out.  
  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread Walter Prins
On 24 August 2010 17:47, aug dawg  wrote:

> if searcher in database:
>> # Figure this out.
>>  if "exit database" in command:
>> print "Bye!"
>> sys.exit()
>>
>
The first thing that caught my eye was the "#figure me out" line -- python
is expecting a statement there, a comment doesn't count.  You can use "pass"
for the time being.  (See
http://docs.python.org/reference/simple_stmts.html#grammar-token-pass_stmt)

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases in Python

2010-08-24 Thread aug dawg
It says that it's on line 25, on the print("Bye!").
Forgot to say that.


On Tue, Aug 24, 2010 at 12:44 PM, aug dawg  wrote:

> The other day, I wrote a little database just to fiddle around, but when I
> try to run it it says that it has an unexpected indent. From what I can
> tell, it doesn't. Here's the code. I'm using SPE.
>
> database = []
> datafile = open('/home/~/the-db/data')
> for line in datafile:
> database.append(line)
>
> while tf2 != True:
> command = raw_input("Enter a command. >> ")
>
> while tf != True:
>  if "add" in command:
> adder = raw_input("What to add? >> ")
>  data_base.append(adder)
> if "no more" in adder:
> tf = True
>
> if "read" in command:
> print(database)
>  if "search" in command:
> searcher = raw_input("Enter term to search >> ")
>  if searcher in database:
> # Figure this out.
>  if "exit database" in command:
> print "Bye!"
> sys.exit()
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Databases in Python

2010-08-24 Thread aug dawg
The other day, I wrote a little database just to fiddle around, but when I
try to run it it says that it has an unexpected indent. From what I can
tell, it doesn't. Here's the code. I'm using SPE.

database = []
datafile = open('/home/~/the-db/data')
for line in datafile:
database.append(line)

while tf2 != True:
command = raw_input("Enter a command. >> ")

while tf != True:
if "add" in command:
adder = raw_input("What to add? >> ")
data_base.append(adder)
if "no more" in adder:
tf = True

if "read" in command:
print(database)
 if "search" in command:
searcher = raw_input("Enter term to search >> ")
if searcher in database:
# Figure this out.
 if "exit database" in command:
print "Bye!"
sys.exit()
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases

2006-04-14 Thread Alan Gauld
> I have some database files that are written in visual foxpro.  I want to 
> be
> able to access them, read them and amend them.  Can I do this with python?

I think you will need to use the OCDB adapter.
Although there may be a Fox adapter out there somewhere, but I haven't
seen any references to it.

> Are there any good links or websites that would specifically deal with
> interrogating visual foxpro databases with Python?

Not that I know of, only the standard Python DBI pages.

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Databases

2006-04-13 Thread mhansen
I just googled "foxpro python" and this link will probably help.

http://mail.python.org/pipermail/db-sig/2001-May/001782.html

I also posted a link a couple of days ago that has a nice PDF of the
Python DB-API which I hope the ODBC driver mentioned in the mail message
above uses.

Mike

- Original Message -
From: John Corry <[EMAIL PROTECTED]>
Date: Thursday, April 13, 2006 3:58 pm
Subject: [Tutor] Databases

> Hi,
> 
> I have some database files that are written in visual foxpro.  I 
> want to be
> able to access them, read them and amend them.  Can I do this with 
> python?
> Are there any good links or websites that would specifically deal with
> interrogating visual foxpro databases with Python?
> 
> I have limited knowledge with databses.  I have created and 
> modified some
> gadfly databases but on a very simple level.
> 
> Any help would be greatly appreciated.
> 
> Thanks,
> 
> John.
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Databases

2006-04-13 Thread John Corry
Hi,

I have some database files that are written in visual foxpro.  I want to be
able to access them, read them and amend them.  Can I do this with python?

Are there any good links or websites that would specifically deal with
interrogating visual foxpro databases with Python?

I have limited knowledge with databses.  I have created and modified some
gadfly databases but on a very simple level.

Any help would be greatly appreciated.

Thanks,

John.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor