Dealing With Mysql Through Perl
i'm working with a mySql database. i have accessed the database through perl.
now i want to know how i can store images in the databases through perl and how to retrieve it..
does anyone have an idea abt this?
View Complete Forum Thread with Replies
Related Forum Messages:
MySQL, Perl CGI
I'm developing a simple computer helpdesk system with MySQL as the backend and Apache/CGI/Perl as the user interface. I've sucessfully set up the part where a user enters an issue via HTML form and "submits" it to the MySQL database. My question is: I have it set up where the user posts the issue to the database, the database auto_increments an issue_id number field. How do I return that issue_id number back to Apache so that the user can see it (and use it as a reference number)?
View Replies !
Perl-DBD-MySQL
I have a binary distribution of MySQL 4.0.20 installed in /usr/local/mysql. Therefore, the only libmysqlclient file I have is libmysqlclient.a (static library). And also, Perl:DBI already installed. I'm trying to install perl-DBD-MySQL-2.9004 from source. What should I add to 'perl Makefile.PL' as arguments to make sure it finds the static library? I've tried 'perl Makefile.PL --libs=/usr/local/mysql/lib/libmysqlclient.a and gotten this: --------------------------------- [root@localhost DBD-mysql-2.9004]# perl Makefile.PL --libs=/usr/local/mysql/lib/lib/mysqlclient.a I will use the following settings for compiling and testing: cflags (mysql_config) = -I/usr/include -mcpu=pentiumpro libs (Users choice) = /usr/local/mysql/lib/lib/mysqlclient.a nocatchstderr (default ) = 0 nofoundrows (default ) = 0 ssl (guessed ) = 0 testdb (default ) = test testhost (default ) = testpassword (default ) = testuser (default ) = To change these settings, see 'perl Makefile.PL --help' and 'perldoc INSTALL'. Unrecognized argument in LIBS ignored: '/usr/local/mysql/lib/lib/mysqlclient.a' Using DBI 1.30 installed in /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBI Writing Makefile for DBD::mysql [root@localhost DBD-mysql-2.9004]# --------------------------------- What should I do to get DBD-MySQL to install correctly?
View Replies !
Using Perl With Mysql
I have heard that if you want a view with mysql, perl is one iof the best applications to use. I want to make a user interface with perl that will prompt the user to enter values and then those values will be stored into the database. I'm just started to learn how to use perl, can anyone give me a little help with writing the code?
View Replies !
Perl DBD::mysql - Using Arrayref
I have an app where I would like to display a returned table with column headings as specified in the inquiry (select), while preserving the column sequence of columns as specified in the original inquiry - without having access to the original inquiry. If I use the fetchrow_hashref method, I can determine the column headings, but I lose the sequence. If I use fetchrow_arrayref, I preserve the sequence, but I lose the column headings. I suspect there is an easy answer. Anybody have it?
View Replies !
Perl And Mysql Datetime
I am trying to have an update form for a datetime field. I've been looking all morning and haven't been able to find any examples of how to do it. I have the date in the form formatted by perl like this: 08-14-2006 11:29:28 and when I do the update to mysql nothing happens. It does not work. I need to make it so the user can put the time the student left.
View Replies !
Perl/mysql On Linux
i am not getting the output for the following code (given below) in apache server on linux. but i do get ouput in perl interpreter please replay me . vinaykumarms@rediffmail.com #!/usr/bin/perl print "ContentType: text/plain "; use DBI; # Connecting to the database # Replace DATABASENAME with the name of the database, # HOSTNAME with the hostname/ip address of the MySQL server. $drh = DBI->install_driver("mysql"); $dsn = "DBI:mysql:database=vinay;host=localhost"; $dbh = DBI->connect($dsn,"",""); # Select the data and display to the browser my $sth = $dbh->prepare("SELECT * FROM login"); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { print "Found a row: id = $ref->{'id'}, name = $ref->{'name'} "; } $sth->finish(); # Disconnect from the database. $dbh->disconnect();
View Replies !
Verifying Mysql Writes (perl)
What is a proper way of verifying that a mysql write was successfull, and to retry if it wasnt? In my perl script I add records through: my $dbh=DBI->connect($dsn, $db_user_name, $db_password); my $sth=$dbh->prepare("insert into TABLE (X, Y, Z) values ('1', '2', '3')"); $sth->execute; $sth->finish; I have noticed that from time to time this fails, due to limitations of my webhost. I thus want to do a check after the write, that it actually happened, and if not redo.
View Replies !
Unable To Connect To Mysql Via Perl
I am attempting to connect to my mysql using a perl script, and keep getting an error message that tells me the I am missing a sub routine. I have installed DBI and DBD::mysql but still can not use my $dbh = open_dbi($db,$username,$password) I am assuming that open_dbi is not installed, does anyone know of another, or better way to access mysql via perl.
View Replies !
Installing MySQL 5 Perl DBI Must Be Installed?
the steps to installing MySQL 5 on Red Hat Linux 9? When I follow the steps as outlined in the manual or Red Hat text I get an error that Perl DBI must be installed. After attempting to download the Perl DBI; that failed because the server was not availabe. Eventually I was able to download some Perl stuff, but not the DBI. Here is the problem at its root. Where is the information to handle all of the error messages? Where is the source of knowledge to work around these problems?
View Replies !
Retreiving MySql Data With Perl (DBI)
I have been trying to retrive data out of MySql data file using DBI and Perl for a while with no luck. I get message "Can't locate loadable object for module DBI in @INC (@INC contains: C:/Program Files/Perl/lib C:/Program Files/Perl/site/lib .) at C:/Program Files/Perl/lib/DBI.pm line 258" I have DBI.pm in above respected directories. I have no problem retreiving data out of flat files ie simple text file with delimiters. I use windows xp,Perl,Apache server and MySql server at home with no other problems.
View Replies !
Dealing With NULL
Is there a why to instruct MySQL to deal with NULL values in a particular way? For the following query, I want the result to be zero and not NULL if v1 or v2 is NULL: SELECT t.v1 * t.v2 FROM table1 t; For the following query, I want no spaces and not NULL to be concatenated if v2 is NULL: SELECT CONCAT(t.v1," ",t.v2) FROM table1 t;
View Replies !
Dealing With Time
I have a database that I have written the time in to (format hh:mm:ss) TIME field MySQL. I also have a DATE field. I'd like to check and see if the entry is more than 2 hours old, and if so, send an email message. Is there an easy way to compare the current time to the entry and determine if it is more than 120 minutes old?
View Replies !
Dealing With Constants
I will be using MySQL's math functionallity to solve some fairly long calcuations, and will be using PHP to interface to MySQL. I will have various constants that are used in the equations. Instead of typing the numerical constant each time, I would like to assign a variable to improve troubleshooting, changing the constants, and readability. I don't, however, want to store my constants in a table or do anthing that will make MySQL slow down each time a query is run. I have done similar things when dealing with a compiled program, but don't know if there are ways of doing this MySQL or PHP.
View Replies !
MySQL/Perl Book Recommendation For A Beginner?
Here's the situation: I have a Perl-based forum that I wrote myself. It currently supports user accounts, but these are stored in a flat text file (as is everything else for that matter). I'm looking to convert this to a MySQL database so that I can do more with that information, but with less processing time (reading through that huge text file to find something isn't very efficient). In the future I hope to move the whole forum over to MySQL, but I thought a good starter project would be just one aspect of it. At this point I am looking for recommendations on good books for someone moderately experienced with Perl, but who has NO experience with MySQL or anything similar. Since I'd prefer to integrate this with my existing script, I'd rather stick with Perl and not learn PHP at this time. So far it seems like "MySQL and Perl for the Web" is a good - are there others? I prefer reference-style texts with useful code examples, rather than lesson-style books.
View Replies !
Calling MySql Select Procedures In Perl
I am trying to call a "select" stored procedure from perl. I am not quite sure how to do it. Here is the stored procedure: CREATE PROCEDURE spTest() begin select x AS X from tblTest; It works fine when called from within MySQL. mysql> call spTest(): +------+ | X | +------+ | 24 | | 3 | +------+ I have the following code in perl: my $spt = $db->prepare("Call spTest()"); $spt->execute(); $spt->bind_columns($id); while($spt->fetchrow_array()){ print "X = $id"; } I get an error that says I need to use "select into". How do I call this procedure from perl?
View Replies !
Query Dealing With Distance
I am trying to query a MySql database based on Lat and Long that is stored in the Database using a formula (that I have and know works just need to convert to Mysql) to figure out distance on a globe. The Results need to be within a set distance, say 50 miles from a center point. Now the question is... What would be the most effienct way of doing this without overly taxes my system resources, as the search could be from a very large table. The search will be limited to no more then 50 returns, from possibly 15K entries to start with. The only entries in the database that are used in this problem are Latitude and longitude, everything else is just display information for that location. If you need the equation I am using please just ask, it is trig dealing with Cos, sin, and atan2 functions.
View Replies !
Dealing With Foreign Languages
mysql dealing with foreign languages such as chinese, french, etc? Are there certain things I have to do to make mysql recognise the foreign languages? Also are there certain things I have to do to view the foreign languages?
View Replies !
Dealing With A Table Of Keywords
I need to achieve something with the least amount of processing possible and hoping for some advice on the best way forward. I have a form where users choose a category and submit a list of keywords separated by commas. From this I split the string and create an array of 10 keywords. I also have a database table which relates categories to keywords so category_id and keyword as a composite key. I can't have any repeated relations and I can't have anymore than 100 rows per category_id. So foreach keyword i need to check if it already exists for the given category_id, if it doesn't then insert it but also need to ensure I don't go over 100 rows for that category. I want to tried and avoid lots of queries in loops etc. How might I go about achieving the above in the most efficient way possible?
View Replies !
Dealing With Null Values In An Expression
I am trying to return age in Days as follows: select frmCode, (ageYears*365+ageMonths*30+ageWeeks*7+ageDays) as AgeInDays from sdata; i realised that if one of those columns has a null value, the whole expression evaluates to null. IS there a way to get around while creating a view, or do i need to write a StoredProcedure and have a logic to ignore the null values.
View Replies !
Storing As Datetime And Dealing With Timezones
We are storing dates in MySQL as type datetime instead of unix timestamps which some people do. We have a user table we are storing the offset of a users timezone in (-1, -6, etc). What do we need to do to ensure all time is uniform in relation to their offset taking into considering this software will be deployed on many different hosts/servers? I assume we need to set the DB connections timezone? SET time_zone = timezone; Should this be set to 0? So we always have an offset of 0? Then when retrieving the data we can use the CONVERT_TZ() functon to convert it to the users offset? Would this be better handled by PHP?
View Replies !
Perl DBI / SQL
I need to know how to retrieve through Perl DBI a listing of possible ENUM elements from a field for processing under a CGI script. If all I need for this is some form of SELECT statement, please provide a code snippet of this so I can do it. I want to make my code so I'm not having to edit hard-coded Perl CGI scripts if/when I add new elements to the ENUM field.
View Replies !
PHP Or Perl?
As part of my own learning mysql project I'm planning to build databases for all my books and DVD's. Stephen Hawking is probably a better typist than I am so I plan to use barcodes to get the info ,taking the information from various web sites. People tell me that PHP is THE way to do database work with mysql. The thing is, I'm familiar with Perl and it has all kinds of neat string manipulation stuff and LWP. Does PHP have comprable libraries (especially LWP) and how difficult is it to move from Perl.
View Replies !
Fw: PHP Or Perl?
Do've an example on using Rebol to connect to mySQL via TCP/IP? How do you do it? How do you execute SQL quieries? Return results etc ? Do you use some kind of "middleware" that your communicating to from Rebol via TCP/IP which gets the data for you?I'm actually a Delphi, Java, VB, Perl & Ruby developer (done alittle Rebol before) but found it strange that your using TCP/IP to communicate with mySQL
View Replies !
Select Via Perl
I am trying to read a file and see if the contents of it exists in the DB or not and am trying to do it via a Select.I try to do a select * into outfile /tmp/result.txt from table where field like "%$var%"; but it always goes through the first two lines of the input file and then says the file already exists. Is this because I read each line of a file in a for loop in perl and the mysql query tries to recreate the outfile each time? Is there any other way I can dump the results of the select to a file of some sort?
View Replies !
PHP Or Perl? (or Rebol Via TCP/IP)
Do've an example on using Rebol to connect to mySQL via TCP/IP? How do you do it? How do you execute SQL quieries? Return results etc ? Do you use some kind of "middleware" that your communicating to from Rebol via TCP/IP which gets the data for you? I'm actually a Delphi, Java, VB, Perl & Ruby developer (done alittle Rebol before) but found it strange that your using TCP/IP to communicate with mySQL.
View Replies !
Error In Perl
I receive the following error when I try to acces MySQL 4.1 Client does not support authentication protocol requested by server; consider upgrading MySQL client I conntect with Perl in this way : $dbh = DBI->connect("DBI:mysql:dbname:localhost","dbuser","dbpass") or print"I can't connect" .DBI->errstr;;
View Replies !
Uninstall Perl (DBI)
i try to install Mysql Server V5 on a Redhat 5 Enterprise. But the RPM needs Perl (DBI) so I install it following the install guide provide on this site. But it' seems to not be detected by the rpm package when installed.
View Replies !
Perl Dbi And Bitfields
In the past I encoded some bit fields into hex and stored them in a short string. I now want to be able to use sql to select records according to settings of various 'flags'. So I have changed the field to a bit field and have succeded in populating it. I can display the vaules using bin(flags+0) as a string of 1 & 0s but when I try to get the value back into a perl variable from a select * it always comes back as 0?
View Replies !
Can't Get Perl To Connect
I am just trying to connect and it wont give real errors like PHP it just says internal server error. #!/usr/bin/perl use warnings; use strict; use DBI; $dsn = 'dbi:mysql:dbname=Location_Test'; $user = 'lmayer'; $password = '*******'; $dbh = DBI->connect($dsn, $user, $password, { RaiseError => 1, AutoCommit => 0 }) I can't make this work at all. I know its configured correctly since all the other pages work. I connect fine at the command line so I know the username and password work.
View Replies !
Perl Script
Is it possible to have MySQL execute a Perl script? I need to run the script upon insertion of a row into a MySQL table. I've seen myperl, but that appears to execute Perl syntax from within MySQL and won't meet our needs
View Replies !
How To Upload Images With Perl
I want to upload an image from a form, store it in the db, then retrieve it and display it on an HTML page. I am looking for a Perl code example to do the store and retrieve.
View Replies !
Getting Last Auto Increment ID (perl DBI)
i am inserting a new line into a table with an auto incremented unique ID. after that i want to add a row to another table that will cross reference with using the ID from the first. what is a reliable method of performing this? selecting the highest ID is open to possible race errors so i'm not keen to do it that way. can it be done in one line?
View Replies !
Authentication Failing In Perl DBI Script
#! /usr/bin/perl use DBI ; use strict ; use CGI ; my ($cgi) = new CGI ; my ($dsn)="DBI:mysql:dr:localhost"; my ($user_name) = "fubar" ; my ($password) = "secret" ; my ($dbh,$sth) ; my (@ary) ; $dbh = DBI->connect ($dsn, $user_name, $password, { RaiseError => 1 }); , and on MySQL, at the command prompt, I've typed this: grant all on *.* to fubar identified by "secret" ;
View Replies !
Blob Update In Perl DBI Gives Syntax Error
I have a Perl app that stores pictures in a blob. Now I want to load a thumbnail version of the picture into another blob column, but the update fails with a syntax error. I'm able to insert the new record, with blobs, into a separate table, but can't update the original record. Is it not possible to update blobs?
View Replies !
LOAD DATA LOCAL INFILE And Perl DBI/DBD
For the past several months we have been using LOAD DATA LOCAL INFILE to bulk load tables within Perl modules. Recently, someone thought it would be a good idea to upgrade the Solaris machines - I'm thinking it wasn't that good an idea :-( We are now running MySQL 4.0.18 and the DBI version is 1.35. Now, our scripts are failing with the dreaded "The used command is not allowed with this MySQL version" message. Here's what I know at the moment: 1. mysqld has local infile enabled. 2. mysql client can perform a LOAD DATA LOCAL INFILE 3. dbimon cannot perform a LOAD DATA LOCAL INFILE (same message as above). So as I understand this, DBI is somehow not allowing the local option. I tried adding the local_infile=1 option on the DSN, but that didn't help (if there was an error, it was silently ignored). Two questions: 1. How can I get the LOCAL option working? 2. How can I identify the source of the problem better so we don't waste more time in the future?
View Replies !
Question On Selecting From A Large Table In Perl
I have a large table with 4 million rows. I need to do an operation on each of the rows. I am using Perl. When I use the following code on a small table, it works just fine but on the large table, it gets stuck on line 3. As soon as it executes line 3, my hard drive starts going and keeps on going with no end. It never reaches line 4. My diagnosis follows the code fragment below: -------------------------------------code fragment begin 1 my $sql = 'select myColumn from myTable'; 2 my $sth = $dbh->prepare($sql) || die ("dbh prepare failed "); 3 $sth->execute() || die ("execute sth failed"); 4 my $colValue; 5 $sth->bind_columns($colValue); 6 while ($sth->fetch()) { 7 do something to $colValue; 8 } -------------------------------------code fragment end I think this is because mySQL is trying to load all 4 million rows into memory. Is there a way, perhaps a command line switch, to delay this so that it processes one row at a time. I have tried adding SQL_NO_CACHE to my SELECT statement but that did not make any difference at all. On a related note, when I was trying to export the four million rows using mysql command line, I had a similar problem but I found the -q command line switch for mysql command line (From the manual: -q or --quick means "Don't cache result, print it row by row.") I hope there is something similar for my Perl problem above too. Or am I doing something completely wrong in the way I am doing this? I am a newbie to mySQL.
View Replies !
How To Generate Html Output For Query Result With Perl
I can generate the html with the command like: >mysql -ppassword -uusername -H -e "select distinct depID from tabledepart" databasename but i need to know how to generate html output if i already connected with a database, and how to pass the html result to the perl program.
View Replies !
ERROR 2002 (HY000): Can't Connect To Local MySQL Server Through Socket '/var/lib/mysql/mysql.sock' (13)
I have a problem connecting to sql and can't find anything on the net to solve the problem. I have some sql databases running on a server. when I'm root on the server and I want to login to sql I do "mysql -ustudent -p -Dwordnet30 and it works fine. when I'm logged in with the user account on the server, i get this error message: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) so with the same user name in mysql, i can log on when i'm root, but not when i'm the user. the grant table for the user looks like this: Code:
View Replies !
Can't Connect To Local MySQL Server Through Socket '/home/data/mysql/mysql.sock' (13)
I just installed mysql on linux. If I open a terminal, su to root, then type "mysql", I am able to connect to the server and run my queries. If I exit out of su so that I am my own id (baisley) and type "mysql", I get this error: Can't connect to local MySQL server through socket '/home/data/mysql/mysql.sock' (13) Any idea why? mysql.sock has full permissions (read/write/execute), so it should be accessable by user baisley. If I am baisley and I run "mysql -u mysql" (as mysql is the user that the RPM set up), it will connect. What I would like to be able to do is run this without having to be user mysql all the time. How do I go about setting that up, or is it better to run all my queries/make tables as 1 user?
View Replies !
|